|
Here is the compiled code:
x = double.MaxValue;<br />
<br />
00000020 mov dword ptr [ebp-10h],0FFFFFFFFh<br />
00000027 mov dword ptr [ebp-0Ch],7FEFFFFFh<br />
<br />
y = double.MaxValue;<br />
<br />
0000002e mov dword ptr [ebp-18h],0FFFFFFFFh<br />
00000035 mov dword ptr [ebp-14h],7FEFFFFFh<br />
<br />
z = x + y - y;<br />
<br />
0000003c fld qword ptr [ebp-10h]<br />
0000003f fadd qword ptr [ebp-18h]<br />
00000042 fsub qword ptr [ebp-18h]<br />
00000045 fstp qword ptr [ebp-20h]
The actual calculation is done in the FPU, storing the result of the first calculation internally. It looks like the datatype used internally can handle larger values than a double, as the result of the calculation is correct.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I have a windows form application that works well in my computer in debug and release modes from IDE and windows explorer. I do XCOPY deployment on other computer. When I run the applicaiton there, it gives System.TypeInitialization exception.
As expected, this exception is thrown when I call a class with only public static variables...no constructors, propterties and methods.
How can I solve this issue?? Please help me
Cheers
CNU
|
|
|
|
|
This may seem stupid, but it's the most common mistake with XCOPY deployment. Did you make sure you copied all the .DLL files in the bin folder to the applications deployment folder? Did you reference some other assembly that's registered in the GAC on the development machine, but is not deployed to the target machine?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I solved that problem...and you are absolutely right.
One of the dll files used has CopyLocal value set to false. It worked in my system as the dll was copied to GAC.
Thanks a lot for your help.
|
|
|
|
|
No problem!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have written an AVLTree class and I was doing some benchmarking using System.Collections.Hashtable as a comparison. And I was surprised by the results. (I am self-taught and so I never had a college level data structures class so please excuse my ignorance.) I did an insert of 1,000,000 random integers into each (using System.Random with a maximum of 10,000,000) followed by 100,000 random (using System.Random with a maximum of 1,000,000) key searches on each. Each time the results were pretty much as follows:
AVLTree test:
Inserts: 951625 - Height: 23
Time: 10:435 sec - Memory: 45.892 KB
Hashtable test:
Inserts: 951803
Time: 4:977 - Memory: 46.723 KB
AVL lookup performance test
Found: 9514 - Time: 350 ms
Hashtable lookkup performance test
Found: 9422 - Time: 70 ms
I tried both Hashtable.ContainsKey and Hashtable.Item with the same "lookup" results. The only thing that seems to vary is that sometimes the Hashtable doesn't use up so much memory (I've seen as low as 32 KB).
I even ran ANTS Profiler on my code to improve the data structure's performance. But I don't see where I could squeeze out another 6 seconds on inserts and while 350 ms isn't anything to laugh at it's much more than 70 ms.
I thought that trees were super efficient data structures used for high speed updates/queries and large amounts of data. (I know this isn't the only application for trees but this is the problem I'm looking to solve). Based on what I had read I decided to put the time in to learn about trees and implement one in a scenario at work where I needed high performance.
So my question is, "When would I want to use a tree instead of a hashtable for heavy data indexing?". I may be a rookie on this one but I'm not proud so I would be happy to send the code in question to anyone interested in my question.
|
|
|
|
|
IMO Hashtables are best for this type of thing. Trees are better if you need partial matches.
One reason why Hashtable runs so fast, it has a native runtime implementation, so even if you duplicate the C# code for it, it will probably be 2-3 times slower.
I have run some benchmarks on a Blowfish implementation i did. Quite suprising results.
C#: 5MB/s
C# optimized: 12MB/s
MC++ optimized managed: 35MB/s
MC++ optimized mixed: 45MB/s
You can squeeze alot of speed using some native code.
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
leppie wrote:
IMO Hashtables are best for this type of thing. Trees are better if you need partial matches.
By partial matches do you mean multi-column keys like in a database index? Or even breaking up a key into segments like you might do for an IP address?
leppie wrote:
One reason why Hashtable runs so fast, it has a native runtime implementation
Based on what you say, it makes sense that a hashtable would be faster because of native code, but I'm also interested in why a hashtable would be better in a general sense.
|
|
|
|
|
|
Thanks,
I appreciate the feedback.
|
|
|
|
|
leppie wrote:
it has a native runtime implementation
Probably Im misunderstanding you but I think thats not correct. Ive used Reflector and the HashTable implementation seems to be completely managed.
|
|
|
|
|
I need someone to point me into a direction.
I need to be able to accomplish the following ( request/response ):
1) send an xml document to an ip address and a specific port
2) listen for the response document also an XML document.
Upon recieving the request document the connection is broken imediately.
After the XML server is ready to return the reply document, a new connection is
established using an address supplied with the orginal request.
BTW I am new to sockets so please be patient with me.
Things I need to do?
1) open socket to server and steam the xml request doc to the server.
2) Listen and capture the response document and write it to disk.
|
|
|
|
|
Take a look at the MSDN docs for the Socket[^] class and its members. They provide many code examples which should give you a starting point.
www.troschuetz.de
|
|
|
|
|
Hi there!
I am trying to save different .swf files on my local machine.
Actually this is already working with the below code.
Unfortunately (how I already figured while writing the code) The file is saved, but somehow corrupted.
Is there maybe a way more simple way to get the Response of an URI into a string (or, let's say a buffer) and save it on my disk?
Below is the code I came up with (within a C# web application):
// init
bool debug = false;
// this is where I get my test-swf, you can have a look at it at:
// http://www.styte.com/3.swf
// it may look strange, what I am trying to do is to read some php-created
// swf's into my .net application....
string url = "http://www.styte.com/trans.php?&bild=3.swf";
// work
Uri fileUrl = new Uri(url);
// Create 'FileWebrequest' object with specified Uri.
WebRequest myFileWebRequest = (WebRequest)WebRequest.Create(fileUrl);
// Send 'FileWebRequest' object & wait for response.
WebResponse myFileWebResponse = (WebResponse)myFileWebRequest.GetResponse();
// Get stream object associated with response object.
Stream receiveStream = myFileWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("windows-1252"); //("utf-8");
// Pipe stream to higher level stream reader with req. encoding format.
StreamReader readStream = new StreamReader (receiveStream, encode);
if (debug==true) Response.Write("\r\nResponse stream received ");
int numChars = 1;
Char[] read = new Char[numChars];
// Read "numChars" characters at a time.
int count = readStream.Read ( read, 0, numChars );
if (debug==true) Response.Write("(count): "+count.ToString()+" File Data...\r\n");
//Response.ContentType = "application/x-shockwave-flash";
//Response.AddHeader("Content-Type", "application/x-shockwave-flash");
FileStream fs = File.Create(@"C:\Inetpub\wwwroot\leilac\uploads\test.swf");
BinaryWriter bw = new BinaryWriter(fs);
while (count > 0) {
String str = new String(read, 0, count);
bw.Write(str);
Response.Write(str);
count = readStream.Read(read, 0, numChars);
}
bw.Close(); fs.Close();
if (debug==true) Response.Write(" ");
// Release resources of stream & response object.
readStream.Close();
myFileWebResponse.Close();
Response.End();
Appreciate any comments/help.
Sasch, styte, http://www.styte.com/
|
|
|
|
|
I believe that you should skip the encoding.
---
b { font-weight: normal; }
|
|
|
|
|
Hey Guffa!
Hmmm, I was thinking about that from the beginning, but how to do so?
S.
|
|
|
|
|
sascho wrote:
Encoding encode = System.Text.Encoding.GetEncoding("windows-1252"); //("utf-8");
// Pipe stream to higher level stream reader with req. encoding format.
StreamReader readStream = new StreamReader (receiveStream, encode);
if (debug==true) Response.Write("\r\nResponse stream received
");
Instead of using a StreamReader, have you tried using a BinaryReader[^]? You don't have to specify an Encoding with it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You could also try the following (very simple) code:
System.Net.WebClient wc = new System.Net.WebClient();
wc.DownloadFile(URIString,FileNameString);
maybe this is not that complicated for such a trivial task.
best regards
jkersch
|
|
|
|
|
Is it possibe to create a transparent avalon application? And would alpha-blending, blur and other effect's work normally? It's hard to believe that this could be done in XP because programs aren't textures unlike in Vista. But on the other hand, didn't they make those cool blur effects in Vista's IE7 with avalon? (and as you all know, WinFX is also available for XP) If not, then how?
|
|
|
|
|
You should try VG.net[^], their newest version can show graphics in an alpha-blended window!
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Not only that, but it's incredibly easy.
For a really basic translucent form, just create a Picture in the designer (instead of the default Form in the application), and then put this code in your picture class:
[STAThread]
static void Main()
{
TranslucentForm form = new MainPicture().DisplayInTranslucentForm();
form.Text = "VG.net Calculator";
Application.Run(form);
}
...and set the picture as the startup class. Your picture will then display on its own with true transparency and translucent (alpha-blended) effects. VG.net also has some new additions to make it extremely simple to allow custom window moving, resizing, minimizing, closing, etc for your translucent UI, with no custom code needed. You can see more here[^].
|
|
|
|
|
|
Marc, that is C# 2.0. And no, there isn't a better way.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|
|
|
Meh. I don't think that it's a good idea for them to support unions in C#. Here's one guy's take on it from Mono: http://lists.ximian.com/pipermail/mono-devel-list/2005-April/011577.html. If you really need a union, you should probably just wrap a C++/CLI union with some managed code.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..."
-Jörgen Sigvardsson
|
|
|
|