Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2001-02

bug or feature?

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

����� ����������

Hello, i'm not subscribed to fpc's mailing list, so it would be great if answer would be forwarded to my e-mail. the problem is:
------------------------------------------------------------

cat d.pas
begin
writeln(round(9/2));
end.
fpc d.pas

Free Pascal Compiler version 1.0.4 [2000/12/18] for i386 Copyright (c) 1993-2000 by Florian Klaempfl
Target OS: Linux for i386
Compiling d.pas
Assembling program
Linking d
3 Lines compiled, 1.7 sec

./d

4

fpc -So d.pas

Free Pascal Compiler version 1.0.4 [2000/12/18] for i386 Copyright (c) 1993-2000 by Florian Klaempfl
Target OS: Linux for i386
Compiling d.pas
Assembling program
Linking d
3 Lines compiled, 1.6 sec

./d

4

------------------------------------------------------------ afair round() should round values, but not truncate.

.... WBR, Roman Hlynovski
----
Бесплатная почтовая служба http://mail.Rambler.ru/ Тетя Ася? Rambler Ego! http://www.rambler.ru/odigo/download.html

Reply by email

Jonas Maebe
to ����� ����������
����� ���������� wrote 17 lines
Hello, i'm not subscribed to fpc's mailing list, so it would be great if answer would be forwarded to my e-mail. the problem is: ------------------------------------------------------------ > cat d.pas begin writeln(round(9/2)); end. > fpc d.pas Free Pascal Compiler version 1.0.4 [2000/12/18] for i386 Copyright (c) 1993-2000 by Florian Klaempfl Target OS: Linux for i386 Compiling d.pas Assembling program Linking d 3 Lines compiled, 1.7 sec > ./d 4

The rounding is done by the FPU, which uses the "round to nearest even" number or something like that. It's not that way (since round(3.1) will return 3), but it is that way with .5. It's calle "accountant rounding" or "financial rounding" or something like that.

Jonas

Reply by email

Unknown author
to ����� ����������: Hello, i'm not subscribed to fpc's mailing list, so it would be great if answer would be…
����� ���������� wrote 30 lines
Hello, i'm not subscribed to fpc's mailing list, so it would be great if answer would be forwarded to my e-mail. the problem is: ------------------------------------------------------------ > cat d.pas begin writeln(round(9/2)); end. > fpc d.pas Free Pascal Compiler version 1.0.4 [2000/12/18] for i386 Copyright (c) 1993-2000 by Florian Klaempfl Target OS: Linux for i386 Compiling d.pas Assembling program Linking d 3 Lines compiled, 1.7 sec > ./d 4 > fpc -So d.pas Free Pascal Compiler version 1.0.4 [2000/12/18] for i386 Copyright (c) 1993-2000 by Florian Klaempfl Target OS: Linux for i386 Compiling d.pas Assembling program Linking d 3 Lines compiled, 1.6 sec > ./d 4 > ------------------------------------------------------------ afair round() should round values, but not truncate.

It works correctly, it does the same as Delphi:

home: >dcc testr.pp
home: >testr
4
home: >

Rounding up happens for 4.51; till 4.5, round goes down.

Michael.

Reply by email

Jonas Maebe
to Jonas Maebe: The rounding is done by the FPU, which uses the "round to nearest even" number or…
Jonas Maebe wrote 6 lines
> 4 The rounding is done by the FPU, which uses the "round to nearest even" number or something like that. It's not that way (since round(3.1) will return 3), but it is that way with .5. It's calle "accountant rounding" or "financial rounding" or something like that.

FWIW: I remember the name again, it's called "banker's rounding"

Jonas

Reply by email