[fpc-pascal]Bug or not Bug
tom_at_work at gmx.at
Thu Mar 11 13:20:03 CET 2004
> > I'm having trouble using Round:
> > ----- [ BOF: test.pas ] -----
> > Program Test ;
> > Uses
> > Math, SysUtils ;
> > Var
> > i : Byte ;
> > Begin
> > For i := 0 to 31 do
> > WriteLn(Format('%d %.8x',[i,Round(Ldexp(1,i))])) ;
> > End.
> > ----- [ EOF: test.pas ] -----
> > ... snip ...
> > Any idea ?
> Round returns a longint. The range of a longint is -2^31 .. (2^31-1).
> The result you had (2^31) doesn't fit in a longint, so this is not a fpc
> As I don't have Delphi, I don't know why Delphi doesn't give an error. It
> be that the Delphi's return value is int64 or cardinal. Or it simply
Delphi's round() returns an int64.
> care about the overflow. What happens in delphi if the formatstring is '%d
%d just indicates that the given value is an integer - the format function
itself does not limit the number of digits (or the range of the given value)
in this case.
More information about the fpc-pascal