[PLUG] Perl round-up
Rich Shepard
rshepard at appl-ecosys.com
Tue Aug 13 17:27:56 UTC 2002
On 13 Aug 2002, Ed Sawicki wrote:
> I need to round a floating point number up to the next integer, regardless
> of what the fractional part is. Here's my first attempt:
>
> if (int($score) != $score) {
> $score = int($score) + 1;
> }
Ed,
Back in the Old Days, before BCD and large-integer math, we just added 0.5
to the float value, then rounded. I believe that the standard C library
rounds up; truncate would "round" down.
Rich
More information about the PLUG
mailing list