Re: Identifying an exact binary representation
- From: feenberg@xxxxxxxxx
- Date: 5 Feb 2007 05:35:16 -0800
On Feb 3, 6:28 pm, "Bernhard Enders" <bgen...@xxxxxxxxx> wrote:
Does anybody know of a Fortran (can be Java also) procedure that is
able to identify if a given floating point number has an exact binary
representation? Is there a simple algorithm for this task that I am
missing? Thanks in advance,
Bernhard.
You'd have to start out with the decimal representation, as has been
pointed out, but couldn't youdo something like this:
Suppose the decimal representation is ".1234". Move the decimal point
to right till you have a decimal integer. Integers never get rounded
on conversion to floats. Then just compare 1234. with .1234*10**4. If
they are unequal, then clearly .1234 got rounded. This obviously only
works within a certain range, but depending on your application that
may be ok.
I must say I have an odd feeling about this suggestion - there are a
lot of smart people in this newsgroup and I wonder they are missing
something - or I am!
Daniel Feenberg
.
- Follow-Ups:
- Re: Identifying an exact binary representation
- From: Brooks Moses
- Re: Identifying an exact binary representation
- From: glen herrmannsfeldt
- Re: Identifying an exact binary representation
- From: mecej4
- Re: Identifying an exact binary representation
- References:
- Identifying an exact binary representation
- From: Bernhard Enders
- Identifying an exact binary representation
- Prev by Date: Re: finding available kind values, precisions and exponent ranges
- Next by Date: Re: Identifying an exact binary representation
- Previous by thread: Re: Identifying an exact binary representation
- Next by thread: Re: Identifying an exact binary representation
- Index(es):
Relevant Pages
|