|
One possibility would be to use the BitConverter class, whether this gives you the results your after I'm not sure, it seemed to work for the values 0 and 1.
<code>
static double BitwiseAnd(double x, double y)
{
return BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(x) & BitConverter.DoubleToInt64Bits(y));
}
</code>
|
|
|
|
|
Hi,
I expect you will want good performance too, so all those Math.Pow operations and stuff,
or the Converter class which needs array objects, are not really appropriate.
There is a rather cheap way of creating "unions" (as in C) by defining a struct with
explicit offsets, so variables of different types can made to overlap. It takes some Marshal
attributes to get it right.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
i'm using this library : http://www.codeproject.com/KB/directx/directshownet.aspx[^]
and i have a problem to use ISampleGrabber with a AVI file reader (IBasicVideo2).
See my code :
<br />
Type comType = null;<br />
object comObj = null;<br />
<br />
comType = Type.GetTypeFromCLSID(Clsid.SampleGrabber);<br />
if (comType == null)<br />
throw new NotImplementedException(@"DirectShow SampleGrabber not installed/registered!");<br />
comObj = Activator.CreateInstance(comType);<br />
<br />
sb = (ISampleGrabber)comObj;<br />
<br />
baseGrabFlt = (IBaseFilter)sb;<br />
<br />
<br />
AMMediaType media;<br />
media = new AMMediaType();<br />
media.majorType = MediaType.Video;<br />
media.subType = MediaSubType.RGB24;<br />
media.formatType = FormatType.VideoInfo;<br />
hr = sb.SetMediaType(media);<br />
if (hr < 0)<br />
Marshal.ThrowExceptionForHR(hr);<br />
<br />
hr = graphBuilder.AddFilter(baseGrabFlt, "Ds.NET Video Capture Device");<br />
if (hr < 0)<br />
Marshal.ThrowExceptionForHR(hr);<br />
<br />
<br />
<br />
<br />
<br />
<br />
Marshal.FreeCoTaskMem(media.formatPtr); media.formatPtr = IntPtr.Zero;<br />
media = null;<br />
<br />
sb.SetOneShot(false);<br />
<br />
sb.SetCallback(this, 1);<br />
The callback is never call.
Someone can help me ?
|
|
|
|
|
There's a forum under that article for a reason.
Have you tried it ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I dont know how to fix my error. Could someone help me out.
I use C# expression.
namespace ConsoleApplication1
{
private void rand_seed()
{
int seed = (int)(time(0));
RandomNumbers.Seed(seed);
}
private double get_RandomNum(double x, double y)
{
return x + (y - x) * RandomNumbers.NextNumber() * (1.0 / RAND_MAX);
}
private static int Main()
{
rand_seed();
double x_cor = 0;
double y_cor = 0;
double x_sum = 0;
double y_sum = 0;
double x_y_total = 0;
int num_darts = 0;
int num_hits = 0;
int num_misses = 0;
double pi_approx = 0;
Console.Write(" Throw the dart: ");
num_darts = SimulateCin.ReadToWhiteSpace(true);
Console.Write("\n");
if (num_darts != 0)
{
for (int i = 0; i < num_darts; i++) // Start of for loop inside the while loop
{
x_cor =get_RandomNum(1.0, -1.0);
y_cor =get_RandomNum(-1.0, 1.0);
x_sum = (x_cor * x_cor);
y_sum = (y_cor * y_cor);
x_y_total = Math.Sqrt(x_sum + y_sum);
if (x_y_total <= 1)
{
num_hits++;
}
else
{
num_misses++;
}
}
} // end of if loop
pi_approx = (1.0 * num_hits /num_misses);
Console.Write(" The value is ");
Console.Write(pi_approx);
Console.Write("\n");
return 0;
}
}
|
|
|
|
|
What is the error message you're getting?
Dave
|
|
|
|
|
I am pretty certain that your methods need to be in a class. Try the following:
namespace ConsoleApplication1 {
public class ConsoleApplication1 {
}
} You may additionally need to set your startup class in the project properties to be ConsoleApplication1.ConsoleApplication1. Hope this helps,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I read this post and that went right over my head.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I recently ran into a problem where the generated WSDL for a class that inherits from IEnumerable<myClass> serializes incorrectly. For example...
[Serializable]
public class myClass : IEnumerable<int> {
public int[] values {
get { ... }
set { ... }
}
public int OtherProp {
get { ... }
set { ... }
}
} Then, in the web service, I have a method...
[WebMethod]
public myClass GetMyClass() {
return new myClass();
} The problem is that the method 'GetMyClass()' is returning an object of type 'int[]' instead of returning a type 'myClass'. Is there some way to override this erroneous serialization so it returns a 'myClass' type instead of the array so I get the 'OtherProp' information as well? It should be noted that removing the base interface from myClass makes the class serialize as I am requesting. However, I would like to use the IEnumerable interface within my code on the server side. Thanks in advance,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
upgrade to .Net 3.0 Service Pack 1.
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
Why will this help? Is there some way to accomplish this in .Net 2.0? Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Skippums wrote: Why will this help? Is there some way to accomplish this in .Net 2.0? Thanks,
no, you can't do it in .net 2.0 because there's a bug in the svcutil.exe.
you need the bug fix that comes with updating to .Net 3.0 SP1.
You can then take the generated code and use it with .Net 2.0
Silence is the voice of complicity.
Strange women lying in ponds distributing swords is no basis for a system of government. -- monty python
Might I suggest that the universe was always the size of the cosmos. It is just that at one point the cosmos was the size of a marble. -- Colin Angus Mackay
|
|
|
|
|
hi there,
i'm trying to insert a text at particular column and row(item) in listview,
and i think it may not be done easily.
e.g.
i have 50 columns in a listview and i add a item and want to insert some text on 1st and 49th column of listview.
insert on 1st column is simple(below), but how can i insert directly in 49th column.
listView1.Items.Add("SOME TEXT", 0);
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Create your subitems, set the text of the one you need (the 49th) and add these subitems to a listviewitem, then add this listviewitem to your listview.
Dave
|
|
|
|
|
yeah but it will add 48 useless subitems, and is there any alternative way to do this, because the index may change then i can use key of the column, but i dunno how ??
EDITED :
SOLVED
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y<p?jxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
modified on Wednesday, February 20, 2008 11:15 PM
|
|
|
|
|
Hi,
I need to display CSH from my app. I call
Help.ShowHelp(this, "myHelpFile.chm", HelpNavigator.Topic, "secondTopic.htm");
and it works fine, but I can't get the help file to expand the nodes and scroll to that specific topic. All it does is displays the topic, but the table of contents stays collapsed.
Is there any way of doing this? I'm using .Net 1.1
thanx
|
|
|
|
|
can anyone help me in this,
i have a multi form app. , i have many open forms, all of the same type(say MyForm)
i want to get the text of a textbox inside each open forms)
as well as many info, including the position of the form
can anyone tell me how to do it
thnx in advance
Web Developer @ Silverkey Egypt
|
|
|
|
|
Maybe add each form to a collection as you instanciate them, then iterate through the collection.
Dave
|
|
|
|
|
1. If it's MDI, you can get the open forms in MDIChildren.
2. If it's not, you can get the open forms in Application.OpenForms.
Expose a get-only string property from MyForm, which return the text box's Text property. Get all the open forms from 1 or 2, check whether it's type of MyForm, cast the form to MyForm and access the exposed property.
|
|
|
|
|
thanks you very much, will try that
Web Developer @ Silverkey Egypt
|
|
|
|
|
Hi, I'm using .Net 1.1 and I'm looking for a way to set a proxy for the axWebbrowser component...
I did googled for a while, but without any luck :/
any ideas?
Thx ahead
|
|
|
|
|
Under .NET 1.1, it uses the proxy settings setup in IE. There is no option to specify your own proxy settings seperately. That didn't appear until .NET 2.0.
|
|
|
|
|
Hi,
How can I add a linear regression line (like Excel's trend line) to a OWC chart object in a Windows Forms application?
Thanks
|
|
|
|
|
Does the CSharp compiler come with all versions of .NET Framework?
Is it totally free to use the CSharp compiler?
_____________________________
...and justice for all
APe
|
|
|
|
|
IT is free to use the C# compiler, as it's distributed with the free .NET SDK.
I don't believe it's distributed as part of the .NET runtime.
|
|
|
|