[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Some modules from Modula-2
Mike wrote:
> I would be interested in seeing the original modules you defined to
> implement RealStr/Conv.
They're gone a long time ago. Should now be in bit hell.
> It is possible to precisely represent
> REAL/LONGREAL numbers since this was also required for the Math(L)
> modules. I mapped the required bit patterns into an integer and
> then interpreted these integers as REALs or LONGREALs. Some numbers
> such as 0.5, 0.25, 0.75, 1.0, etc. are exactly representable so they
> shouldn't cause any conversion problems. Of course, numbers like 0.1
> are not exactly representable because they end up being numbers like
> 3DCCCCCD (REAL) or 3FB999999999999A (LONGREAL). Note the rounding up
> of the last hexadecimal digit since these numbers repeat the `C' or `9'
> patterns forever.
The idea is to get as close an approximation as possible. When
converting a string to real and the floating-point representation is,
say, X, then both succ(X) and pred(X) shouldn't be close to the
intended conversion. succ(X) (pred(X)) are the next larger (smaller)
floating point value to X.
-- mva