Well..... One answer is to use a loop and keep multiplying until u get
something.
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[
mailto:rpg400-l-bounces@xxxxxxxxxxxx]On Behalf Of Doug Palme
Sent: Wednesday, April 04, 2007 8:17 AM
To: 'RPG programming on the AS400 / iSeries'
Subject: RE: Floating point conversion
The issue with that would be I am never going to know for sure what the
power is....
-----Original Message-----
From: rpg400-l-bounces+dpalme=hdsmith.com@xxxxxxxxxxxx
[
mailto:rpg400-l-bounces+dpalme=hdsmith.com@xxxxxxxxxxxx] On Behalf Of James
Rich
Sent: Tuesday, April 03, 2007 5:08 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Floating point conversion
On Tue, 3 Apr 2007, Douglas Palme wrote:
I have a need to convert a floating point to an integer and have run into
a
problem.
The float is declared as an 8f
I thought I could use something like the following:
Eval myint = %int(float)
But it ends up with a zero value..even though the float shows something
like
2.234586785678E-28
This makes sense since 2.234586785678 times 10 to the -28 power is a very
small number indeed. Rounding to the closest integer gives you zero. But
I'm guessing that you want to use the significant portion of the floating
point number and treat that as if it were an integer. There's a problem
with that, and that is that floating point numbers are not exact, so how
do you convert it to an exact integer? You can't, not without some
rounding. Probably the best you can do is multiply by 10 to the 28 power
to get 2.234586785678 and then multiply by some power of ten again to get
number of significant digits you want.
James Rich
It's not the software that's free; it's you.
- billyskank on Groklaw
As an Amazon Associate we earn from qualifying purchases.