IHaveRegistered
Knight
I came across this...
Alrighty, this is what I saw:
I was wonder about two things, one is the answers to the above. The forums I found it at did answer a few, but yea. I thought of another thing...
What one of those two would be faster? For me, the second looks more organized. But both end up accomplishing the exact same task. Is there actually any difference in performance? Or anything else for that matter?
Alrighty, this is what I saw:
http://www.codeguru.com/forum/showthread.php?t=365154 said:Hi all,
Was reading a book today about data types in C# and have a few burning and itchy questions. They're fundamental concepts, but it's more to the details(Computer Science level).
1) Consider the following : Code:
int n, a, b;
and Code:
int n;
int a;
int b;
It's said that the 1st style above will cost some performance loss. Is it true?(even though I know it won't be noticeable)
2) Is it that a long can store the same amount of digits as a double(both are 8 bytes large), only that a double can store decimal digits as well?
3) In C#, a float is 4 bytes, a double is 8 bytes and a decimal is 16 bytes. The decimal data type stores less digits than a float or a double, but how can it take up 16 bytes???!!!
4) A bool requires 1 byte of memory(8 bits). Since we all know that the bool data type can store only a TRUE(1) or a FALSE(0), shouldn't it take up just 1 bit instead of 1 byte? After all, the value 1(TRUE) or 0(FALSE) can be stored in 1 bit, and doesn't require 8 bits(1 byte).
5) Code:
System.Int32 m_myvar = 500;
and Code:
int m_myvar = 500;
When this program is run under the .Net(CLR) enviroment, will the 1st style execute slightly faster(even if un-noticeable) than the 2nd style, because we're using the .Net data type directly?(something like calling the Win32 API directly instead of wrappers like MFC)
6) Code:
float my_var = 1.35F;
I saw the above code in the book today. Is there a real need to add the 'F' behind to tell the compiler that this is a float? I mean, any advantages or practicality reasons behind this?
Thanks!
Xeon.
I was wonder about two things, one is the answers to the above. The forums I found it at did answer a few, but yea. I thought of another thing...
Code:
if( ((from != null) || (from.Map != Map.Internal)) || (!from.Deleted) )
{
//code
}
or
if( from != null )
{
if( from.Map != Map.Internal )
{
if( !from.Deleted )
{
//code
}
}
}
What one of those two would be faster? For me, the second looks more organized. But both end up accomplishing the exact same task. Is there actually any difference in performance? Or anything else for that matter?