List Info

Thread: Re: how to round a floating-point value to an integer value




Re: how to round a floating-point value to an integer value
country flaguser name
Europe
2007-03-20 09:07:30

>But at some point it has to happen, whether u do it urself
>in some code or the arithmetic engine does it on its floats.

Understood. But the difference is that computers round beyond where we humans generally care about. Not that it's actually rounding--as you pointed out in another post--but just the nth digit in an n-precision representation. (Kind of makes you wonder what's lurking at n-plus-one, doesn't it?)  Most programmer-performed rounding comes at the *end* of the computation (where, incidentally, it belongs), when we need to round a number to a reasonable, usable value.

For example, using a few dozen digits of pi, say 3.14159265358979323846264338327950288419716939937510, is probably not going to make a difference unless you're piloting a moon rocket, where you might even want to use an "unrounded" value. Most of us on earth are satisfied with, and able to use successfully, a value of 3.14159. OTOH, rounding pi to 3.142 is probably not a good idea, even for terrestrial apps. Remember when one state (Kansas, Nebraska, or Arkansas, I think it was) wanted to declare pi = 3, which would've made all the wheels in the state turn square overnight? Srt f lk wht wer dng 2 Nglsh <giggle, snerk, chortle>;.

See the Wikipedia article on rounding at http://en.wikipedia.org/wiki/Rounding for an interesting discussion on the principles and pitfalls of rounding.

Speaking of pi, does anyone need a thousand-dp value of it? How about a million-dp value? I have one of each available, but I won't post them here.... A caveat, though: they're text values in Word doc files--converting them to numbers is your problem! (Good luck wit dat, Cholly!)  Or, to impress your friends, you could use 355/113, good to six dp (http://www.math.hmc.edu/funfacts/ffiles/10004.5.shtml).

Deane Rothenmaier
Programmer/Analyst
Walgreens Corp.
847-914-5150

"I am but mad north-north-west. When the wind is southerly I know a hawk from a hand-saw&quot; -- Hamlet (Act II, scene ii)
RE: how to round a floating-point value to an integer value
country flaguser name
United States
2007-03-20 09:29:37
> Remember when one state (Kansas, Nebraska, or Arkansas,
I think it
was)
> wanted to declare pi = 3, which would've made all the
wheels in the
> state turn square overnight?

This isn't quite true, but the truth is equally weird. It
was a bill
with a method to square a circle, which is to find a square
with the
same area as a given circle, using only a compass and a
straightedge.
(Something proven to be impossible). The bill made several
erroneous and
conflicting claims about the value of pi.

http://e
n.wikipedia.org/wiki/Indiana_Pi_Bill

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Userslistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs

Re: how to round a floating-point value to an integer value
country flaguser name
United States
2007-03-20 10:09:12
Deane.Rothenmaierwalgreens.com graced perl with these words
of wisdom:

> Srt f lk wht wer dng 2 Nglsh 
><giggle, snerk, chortle>.

*We*?  Speak for yourself.

I find it intensely irritating to read posts on an email
list like this 
where people write "u" and "ur" when
they're not talking about Burmese 
honorifics or ancient Mesopotamian cities -- it makes the
posts so much 
harder to follow.  Considering that spelling (and case!) are
vitally 
important in a programming language like Perl, one would
hope that posters 
wouldn't deliberately misspell things.

-- 
Ted <fedya at bestweb dot net>
Hmmm....  Eternal happiness for one dollar?  [Pauses] On
second thought, 
I'd be happier *with* the dollar. --Montgomery Burns
<http://www
.snpp.com/episodes/4F01.html>
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Userslistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )