Unnecessary double checks of infinity
Hi all, I'm having a look how floats are printed. Why we check two times if a Float is infinite ? A first time in: Float>>printOn: stream base: base ... self isInfinite ifTrue: [ stream nextPutAll: 'Float infinity'. ^ self sign = -1 ifTrue: [ stream nextPutAll: ' negated' ] ]. ... and a second time in: Float>>absPrintExactlyOn: aStream base: base ... self isInfinite ifTrue: [ aStream nextPutAll: 'Float infinity'. ^ self]. ... the same in Float>>absPrintInexactlyOn: aStream base: base ... self isInfinite ifTrue: [aStream nextPutAll: 'Float infinity'. ^ self]. ... Apparently the last two methods are never called when number is infinite. I remove the second checks and apparently nothing breaks (all number tests are still green). Regards, -- Serge Stinckwic h Int. Research Unit on Modelling/Simulation of Complex Systems (UMMISCO) Sorbonne University (SU) French National Research Institute for Sustainable Development (IRD) U niversity of Yaoundé I, Cameroon "Programs must be written for people to read, and only incidentally for machines to execute." https://twitter.com/SergeStinckwich
https://github.com/pharo-project/pharo/issues/5542 On Sun, Dec 22, 2019 at 5:12 PM Serge Stinckwich <serge.stinckwich@gmail.com> wrote:
Hi all, I'm having a look how floats are printed. Why we check two times if a Float is infinite ? A first time in:
Float>>printOn: stream base: base ... self isInfinite ifTrue: [ stream nextPutAll: 'Float infinity'. ^ self sign = -1 ifTrue: [ stream nextPutAll: ' negated' ] ]. ...
and a second time in:
Float>>absPrintExactlyOn: aStream base: base ... self isInfinite ifTrue: [ aStream nextPutAll: 'Float infinity'. ^ self]. ...
the same in Float>>absPrintInexactlyOn: aStream base: base ... self isInfinite ifTrue: [aStream nextPutAll: 'Float infinity'. ^ self]. ...
Apparently the last two methods are never called when number is infinite.
I remove the second checks and apparently nothing breaks (all number tests are still green).
Regards, -- Serge Stinckwic h
Int. Research Unit on Modelling/Simulation of Complex Systems (UMMISCO) Sorbonne University (SU) French National Research Institute for Sustainable Development (IRD) U niversity of Yaoundé I, Cameroon "Programs must be written for people to read, and only incidentally for machines to execute." https://twitter.com/SergeStinckwich
-- Serge Stinckwic âhâ Int. Research Unit on Modelling/Simulation of Complex Systems (UMMISCO) âSorbonne University (SU) French National Research Institute for Sustainable Development (IRD)â U âniversity of Yaoundé Iâ, Cameroon "Programs must be written for people to read, and only incidentally for machines to execute." https://twitter.com/SergeStinckwich â
participants (1)
-
Serge Stinckwich