Literals/Floating point: Difference between revisions
Content deleted Content added
Kotlin example with explicit types |
Added C# |
||
Line 170: | Line 170: | ||
Why does 6.4.4.2 seem to disallow negative floats? Clearly this isn't the intent... maybe -1.2 is considered to be the unary negation of 1.2? |
Why does 6.4.4.2 seem to disallow negative floats? Clearly this isn't the intent... maybe -1.2 is considered to be the unary negation of 1.2? |
||
--> |
--> |
||
=={{header|C sharp}}== |
|||
Floating point suffixes are not case-sensitive. |
|||
<lang csharp>double d = 1; |
|||
d = 1d; |
|||
d = 1D; |
|||
d = 1.2; //double is the default if there's no suffix |
|||
d = 1.2d; //The suffix is redundant here |
|||
d = .2; |
|||
d = 12e-12; |
|||
d = 12E-12; |
|||
d = 1_234e-1_2; //digit separators are allowed since C# 7 |
|||
float f = 1; |
|||
f = 1f; |
|||
f = 1F; |
|||
f = 1.2f; |
|||
f = .2f; |
|||
f = 12e-12f; |
|||
f = 12E-12f; |
|||
f = 1_234e-1_2f; |
|||
decimal m = 1; |
|||
m = 1m; |
|||
m = 1m; |
|||
m = 1.2m; |
|||
m = .2m; |
|||
m = 12e-12m; |
|||
m = 12E-12m; |
|||
m = 1_234e-1_2m;</lang> |
|||
=={{header|Clojure}}== |
=={{header|Clojure}}== |