View Single Post
Old 02-12-2007, 01:55 PM   #12 (permalink)
IHaveRegistered
Forum Expert
 
IHaveRegistered's Avatar
 
Join Date: Jun 2003
Location: Ontario
Age: 20
Posts: 4,522
Send a message via MSN to IHaveRegistered
Default

Quote:
Originally Posted by Ray View Post
However, if both were AND, this would probably lead to the same performance as it does the same thing (assuming there are no variables that run out of scope). Away from that, you'll find better ways to improve performance than comparing two if's against each other.


-----
1: not sure about that, but under the hood, this should be compiled to just the same code afaik.
2: No, double stores less digits. An integral value like long is stored 'as is'. A floating point value is stored with a mantissa and an exponent to its base. These types are also called 'approximate numbers', as they have a limited precision. You can use double to store much higher values than with int64, but they are of limited precision. Only the higest 16 digits of a number are stored here.
3:decimal has another base. Unlike the other types, it's 10 based, double is 2 based, leading to those wonderful outputs like 0.8 - 0.1 = 0.699999~. And it's not an approximate number. A decimal stores more 'digits' than a double, but less on the left side of the point, it's more precise which is really importent if you're calculating with, say, currencies.
4:1byte is the smallest chunk of memory a processor can handle. Eheres nothing more to say about this, its a technology restriction. Except of: .Net usually pads even 8bit memory to 32bit.
5: No, this is just the same IL code. A difference with this 2 statements is most likley of inaccurate testing - you can't test this only with one run, as other processes on your system can interfer with the test.
6: Try to run it without the F. It won't compile. The F is there to tell the compiler that this constant is a float-type. Without it, the compiler assumes it to be a double and it cant implicitly convert it to float.
For the giant block, yeh. I meant to put "&&" and not the "or" 's. :\

It all seemed pretty interesting, I never thought to stop and think about performance from doing the same thing in such small amounts of ways (as shown in my first post, it's a quote from another site...).

Quote:
Originally Posted by Mordero
yeah storm and ray are right. I didnt even look at them cause i knew the kind of question you were asking (There was a thread that went through an argument dealing with them) and what you wanted to know.
Yeh, I wasn't paying much attention when I cooked up the random code

What thread?
__________________
IHaveRegistered is offline   Reply With Quote