double v. Double?
-
How do these differ? Besides color and case. Console.WriteLine(typeof(double).FullName); Console.WriteLine(typeof(Double).FullName); Both tell me it's a System.Double Thank you, Paul
Actualy they both are the same thing. The base class is
System.Double
whitch is mapped (for many reasons) into thedouble
type. This case is encountered at every standard variable type. Would you prefer to write in your codeSystem.Double myDouble = new System.Double(10);
Or is easier like this ?
double myDouble = 10;
:)
protected internal static readonly ... and I wish the list could continue ...
-
Actualy they both are the same thing. The base class is
System.Double
whitch is mapped (for many reasons) into thedouble
type. This case is encountered at every standard variable type. Would you prefer to write in your codeSystem.Double myDouble = new System.Double(10);
Or is easier like this ?
double myDouble = 10;
:)
protected internal static readonly ... and I wish the list could continue ...
-
In addition to
System.Double myDouble = new System.Double(10);
You can also say
Double myDouble = 10.0;
Jon Sagara Look at him. He runs like a Welshman. Doesn't he run like a Welshman? Doesn't he? I think he runs like a Welshman. Sagara.org | Blog | My Articles
-
How do these differ? Besides color and case. Console.WriteLine(typeof(double).FullName); Console.WriteLine(typeof(Double).FullName); Both tell me it's a System.Double Thank you, Paul
Like Vlad said there are many reasons, the main is that, like C, int should always be mapped to the size appropriate for your processor. So on a 32-bit system this is 32 bits and on a 64 bit system it's 64 bits wide, so System.Int32 and System.Int64 respectively. float and double are done in the same way although I'm not sure what their standing is because to my knowledge float and double are defined by IEEE and doubles are 64 bits by definition. Anyone correct me if I'm wrong Ed
-
Like Vlad said there are many reasons, the main is that, like C, int should always be mapped to the size appropriate for your processor. So on a 32-bit system this is 32 bits and on a 64 bit system it's 64 bits wide, so System.Int32 and System.Int64 respectively. float and double are done in the same way although I'm not sure what their standing is because to my knowledge float and double are defined by IEEE and doubles are 64 bits by definition. Anyone correct me if I'm wrong Ed
One might think that it would work like C, but it doesn't. In C# all the data types are defined with an exact size. The int data type is an alias for the System.Int32 data type, so it will always be 32 bits regardless of the system. MSDN: C# built-in types[^] --- b { font-weight: normal; }
-
One might think that it would work like C, but it doesn't. In C# all the data types are defined with an exact size. The int data type is an alias for the System.Int32 data type, so it will always be 32 bits regardless of the system. MSDN: C# built-in types[^] --- b { font-weight: normal; }
-
One might think that it would work like C, but it doesn't. In C# all the data types are defined with an exact size. The int data type is an alias for the System.Int32 data type, so it will always be 32 bits regardless of the system. MSDN: C# built-in types[^] --- b { font-weight: normal; }
I agree, there is a different conception of the shorthand 'int' between classic C and managed languages using the common type system, since the CTS doesn't consult the system on which it's compiled to see what size an integer should be. However that's not the same as saying 'int' will always represent a 32 bit integer. I think the idea is that if, say, 64 bit systems became the standard, 'int' might eventually map to Int64. Obviously, that would require a release of the framework (or at least the CTS), but the possibility definitely exists, and there are numerous warnings to that effect in the documentation. In such a case, source compiled using 'int' could take on a different meaning than code written using the (more explicit) 'Int32' under the updated type system. That said, do I typically fully qualify all of my integral type declarations? No, not really. Do I lay awake nights worrying about it? No, not really. :)
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’