Faculty of Information Technology
Software Engineering Group

Opened 5 weeks ago

Last modified 5 weeks ago

#288 new defect

Float exponent is not compatible with other dialects (VW, Squeak, Dolphin, ...)

Reported by: nicolas.cellier.aka.nice@… Owned by:
Priority: major Milestone:
Component: default Keywords: Float exponent
Cc: Also affects CVS HEAD (eXept version): no

Description

Currently, exponent and mantissa are defined in term of frexp() function.

They return a significand in interval [0.5,1.0) and exponent accordingly.

Other dialects return the significand in interval [1.0,2.0).
Because they are defined in term of ilogb()/scalb() function.

Thus 1.0 exponent is 1 in stx and 0 in other dialects, making port of some library more difficult than necessary.

I would rather use ilogb() and scalb() for the exponent because they also work if ever the radix of Float implementation is not 2.

There is no sender of exponent/mantissa in base image, so this should be a safe change.

Change History (2)

comment:1 Changed 5 weeks ago by nicolas.cellier.aka.nice@…

More over, exponents also should be compatible with emin and emax

    | fmax |
    fmax := (2.0 nextFloat: -1) timesTwoPower: Float emax.
    self assert: (fmax nextFloat: 1) isInfinite.
    fmax exponent > Float emax
        ifTrue: [self halt: 'How a Float exponent could be greater than maximum Float exponent, emax?'].


comment:2 Changed 5 weeks ago by Jan Vrany

Hi,

nice to see you here!

Now I must admit that I never touched this code nor I feel an expert in FP. What you say makes sense - I have no problem changing #exponent and #mantissa (or any other FP-related code given the change is justified - your word is enough :-) - and accompanied with tests).

Can you provide some tests to star with, or/and (even better) a proposal for a fix?

Note: See TracTickets for help on using tickets.