Literals/Floating point: Difference between revisions

no edit summary
No edit summary
Line 351:
=={{header|D}}==
D built-in floating point types include ''float'' (32-bit), ''double'' (64-bit) and ''real'' (machine hardware maximum precision floating point type, 80-bit on x86 machine) and respective complex number types. Here's information for [http://www.d-programming-language.org/lex.html#floatliteral Floating Literals].
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
 
 
<syntaxhighlight lang="Delphi">
procedure FloatLiterals(Memo: TMemo);
{Delphi has multiple floating number formats}
var R48: Real48; {48-bit real number}
var SI: Single; {32-bit real number}
var D: Double; {64-bit real number}
var E: Extended; {80-bit real number}
var Cmp: Comp; {}
var Cur: Currency; {Fixed point number for currency}
begin
{Various formats that can be used on input or
as constants assigned to various reals.
Pascal automaically converts integer to
reals as long as the real has enough precision
to hold the value. Consequently, all of the
following constants can be assigned to a real.}
D:=1234;
D:=1.234;
D:=1234E-4;
D:=$7F;
{Reals can also be output in various formats.}
D:=123456789.1234;
Memo.Lines.Add(FloatToStrF(D,ffGeneral,18,4));
Memo.Lines.Add(FloatToStrF(D,ffExponent,18,4));
Memo.Lines.Add(FloatToStrF(D,ffFixed,18,4));
Memo.Lines.Add(FloatToStrF(D,ffNumber,18,4));
Memo.Lines.Add(FloatToStrF(D,ffCurrency,18,4));
Memo.Lines.Add(Format('%10.4f',[D]));
end;
 
 
</syntaxhighlight>
{{out}}
<pre>
123456789.123400003
1.23456789123400003E+8
123456789.1234
123,456,789.1234
$123,456,789.1234
123456789.1234
 
</pre>
 
 
=={{header|Dyalect}}==
465

edits