Literals/Floating point: Difference between revisions

no edit summary
m (syntax highlighting fixup automation)
No edit summary
Line 529:
Dim k As Double = 0#
Dim l As Double = 3.141592653589e3#</syntaxhighlight>
 
=={{header|FutureBasic}}==
FB can express floating point literals in several ways.
<syntaxhighlight lang="futurebasic">
local fn DoIt
print "Single:"
single s = 1.0 : print s
s = 123.456 : print s
s = -123.0 : print s
s = 43.1e+5 : print s
s = 43.1E5 : print s
s = 3.1 : print s
s = -123.456e-2 : print s
s = 3.141592653589e3 : print s
print
 
print "Double"
double d = 1.0 : print d
d = 123.456 : print d
d = -123.0 : print d
d = 43.1e+13 : print d
d = 43.1E13 : print d
d = 3.1 : print d
d = -123.456e-7 : print d
d = 3.141592653589e3 : print d
print
 
print "Float:"
float f = 1.0 : print f
f = 123.456 : print f
f = -123.0 : print f
f = 43.1e+5 : print f
f = 43.1E5 : print f
f = 3.1 : print f
f = -123.456e-2 : print f
f = 3.141592653589e3 : print f
print
 
print "CFNumberRef:"
CFNumberRef c = @1.0 : print c
c = @123.456 : print c
c = @-123.0 : print c
c = @43.1e+13 : print c
c = @743.1E13 : print c
c = @3.1 : print c
c = @-123.456e-7 : print c
c = @3.141592653589e37 : print c
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
Single:
1
123.456
-123
4310000
4310000
3.1
-1.23456
3141.593
 
Double
1
123.456
-123
431000000000000
431000000000000
3.1
-1.23456e-05
3141.592653589
 
Float:
1
123.456
-123
4310000
4310000
3.1
-1.23456
3141.593
 
CFNumberRef:
1
123.456
-123
431000000000000
7431000000000000
3.1
-1.23456e-05
3.141592653589e+37
</pre>
 
=={{header|GAP}}==
715

edits