Both sides previous revisionPrevious revision | Next revisionBoth sides next revision |
literals [2018/02/10 14:51] – wolfgangriedmann | literals [2018/02/10 14:52] – wolfgangriedmann |
---|
You can also use a prefix of ''0x'' to specify a hexadecimal value. | You can also use a prefix of ''0x'' to specify a hexadecimal value. |
Sample code: | Sample code: |
<code>Console.WriteLine( "123.45 is a " + (123.45 ):GetType():Name ) // Double | <code>Console.WriteLine( "123.45 is a " + (123.45 ):GetType():Name ) // Double |
Console.WriteLine( "123 is a " + ( 123 ):GetType():Name ) // Int32 | Console.WriteLine( "123 is a " + ( 123 ):GetType():Name ) // Int32 |
Console.WriteLine( "10000000000 is a " + ( 10000000000 ):GetType():Name ) // Int64 | Console.WriteLine( "10000000000 is a " + ( 10000000000 ):GetType():Name ) // Int64 |
Console.WriteLine( "123s is a " + ( 123s ):GetType():Name ) // Single | Console.WriteLine( "123s is a " + ( 123s ):GetType():Name ) // Single |
Console.WriteLine( "123d is a " + ( 123d ):GetType():Name ) // Double | Console.WriteLine( "123d is a " + ( 123d ):GetType():Name ) // Double |
Console.WriteLine( "123dm is a " + ( 123m ):GetType():Name ) // Decimal | Console.WriteLine( "123dm is a " + ( 123m ):GetType():Name ) // Decimal |
Console.WriteLine( "0x111 has a decimal value of " + 0x111:ToString() ) // decimal 273 | Console.WriteLine( "0x111 has a decimal value of " + 0x111:ToString() ) // decimal 273 |
Console.WriteLine( "0b111 has a decimal value of " + 0b111:ToString() ) // decimal 7</code> | Console.WriteLine( "0b111 has a decimal value of " + 0b111:ToString() ) // decimal 7</code> |
| |
For explanations why these suffixes differ from these on C#, please see this X# forum post: [[https://www.xsharp.info/forum/public-product/555-correct-syntax-for-floats|Correct syntax for floats]] (look at the 3rd message from Chris Pyrgas) | For explanations why these suffixes differ from these on C#, please see this X# forum post: [[https://www.xsharp.info/forum/public-product/555-correct-syntax-for-floats|Correct syntax for floats]] (look at the 3rd message from Chris Pyrgas) |
| |
| |