|
|
View previous topic :: View next topic |
Author |
Message |
Einly Guest
|
Round float to the nearest integer |
Posted: Fri Apr 25, 2003 2:54 am |
|
|
Dear all,
If a=ceil(1.9)
Then, a=2
If a=floor(1.9)
Then, a=1
May I know how to round a float number to the nearest integer?
Ex. : 1.9-------2
1.2-------1
1.3-------1
Thanks.
Einly
___________________________
This message was ported from CCS's old forum
Original Post ID: 13988 |
|
|
R.J.Hamlett Guest
|
Re: Round float to the nearest integer |
Posted: Fri Apr 25, 2003 3:08 am |
|
|
:=Dear all,
:=
:=If a=ceil(1.9)
:=Then, a=2
:=
:=If a=floor(1.9)
:=Then, a=1
:=
:=May I know how to round a float number to the nearest integer?
:=Ex. : 1.9-------2
:= 1.2-------1
:= 1.3-------1
:=
:=Thanks.
:=
:=
:=Einly
The normal method, in C, is:
a=floor(n+0.49999);
Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 13989 |
|
|
Einly Guest
|
Thanks:) |
Posted: Sun Apr 27, 2003 1:00 am |
|
|
Thanks
___________________________
This message was ported from CCS's old forum
Original Post ID: 14017 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|