Note: information on this page refers to Ceylon 1.1, not to the current release.
Float
literals
A literal notation for a Float
value.
Usage
A Float
literal can be written in a variety of ways:
variable Float one = 1.0;
one = 1.0000;
variable Float oneMillion = 1000000.0;
oneMillion = 1_000_000.0;
oneMillion = 1.0M;
oneMillion = 1.0e6;
oneMillion = 1.0E+6;
variable Float half = 0.5;
half = 5.0E1;
half = 5.0e1;
half = 500m;
half = 500.0m;
Description
Decimal point
Float
literals almost always contain a decimal point, .
, which:
 separates the fractional part from the whole number part, and
 syntactically distinguishes a
Float
literal from anInteger
literal.
The exception to this rule is any Float
literal with a one of the
"fractional" magnitude suffices (m
, u
, n
, p
, f
).
Decimal magnitude suffices
A Float
literal may be written with a magnitude, a whole magnitude:

k
(kilo), 10^{3} 
M
(mega), 10^{6} 
G
(giga), 10^{9} 
T
(tera), 10^{12} 
P
(peta), 10^{15}
Or a fractional magnitude:

m
(milli), 10^{3} 
u
(micro), 10^{6} (strictly this should be mu (μ), but that would be too hard to type on most keyboards) 
n
(nano), 10^{9} 
p
(pico), 10^{12} 
f
(femto), 10^{15}
For example:
Float million = 1.0M;
Float millionth = 1u;
Grouping digits
An underscore, _
, may be used to separate groups of three digits in the
integer or fractional part of the literal.
Float million = 1_000_000.0;
Float millionth = 0.000_000_1;
Exponential notation
Exponential notation is supported using e
or E
to separate the mantissa
(before the E
) from the scale (after the E
).
Float million = 2.0e6;
Float millionth = 2.0e6;
As a primary
Invoking members of the class Float
directly on a literal is permitted:
Float minusOneHalf = 0.5.negativeValue;
See also
 Numeric literals in the Tour of Ceylon
 Numeric literals in the language specification