[squeak-dev] The Trunk: Kernel-nice.1492.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Nov 24 12:03:28 UTC 2022


Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.1492.mcz

==================== Summary ====================

Name: Kernel-nice.1492
Author: nice
Time: 24 November 2022, 1:03:20.758687 pm
UUID: cec2ead5-112d-5e4f-9ffe-969e3a7f575a
Ancestors: Kernel-ct.1491

Fix a failure to round to nearest Float for large negative exponent when no fraction part is provided.

For example, this should be true:
	
	25e-108 = 25.0e-108.

Because (10 raisedToInteger: exp) isAnExactFloat is false for any exp abs > 22, we shall not recompose the float as integerPart * (base asFloat raisedTo: exponent), that's potentially two inexact operations in a row, and a chance of incorrect rounding.

=============== Diff against Kernel-ct.1491 ===============

Item was changed:
  ----- Method: SqNumberParser>>makeIntegerOrScaledInteger (in category 'parsing-private') -----
  makeIntegerOrScaledInteger
  	"At this point, there is no digit, nor fractionPart.
  	 Maybe it can be a scaled decimal with fraction omitted...
  	 Maybe it can be a Float with a negative exponent"
  	
  	neg ifTrue:
  		[integerPart := integerPart negated].
  	self readExponent ifTrue:
  		["Check that the result is an integer, otherwise answer a Float.  Fractions are /not/ valid literals."
+ 		| temp |
+ 		temp := integerPart * (base raisedToInteger: exponent).
+ 		temp isInteger ifFalse: [^temp asFloat].
+ 		^temp].
- 		 (exponent >= 0 or: [(integerPart * (base raisedToInteger: exponent)) isInteger]) ifFalse:
- 			[base := base asFloat].
- 		^integerPart * (base raisedToInteger: exponent)].
  	(self readScaleWithDefaultNumberOfDigits: 0) ifTrue:
  		[^integerPart asScaledDecimal: scale].
  	^ integerPart!



More information about the Squeak-dev mailing list