[Pkg] The Trunk: KernelTests-nice.313.mcz
commits at source.squeak.org
commits at source.squeak.org
Sun Oct 2 13:19:51 UTC 2016
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.313.mcz
==================== Summary ====================
Name: KernelTests-nice.313
Author: nice
Time: 2 October 2016, 3:19:37.781599 pm
UUID: e6139cfd-b985-42d5-9f24-ffeb0ce8cf6c
Ancestors: KernelTests-mt.311
Test edge cases of Integer>>nthRoot:
=============== Diff against KernelTests-mt.311 ===============
Item was added:
+ ----- Method: IntegerTest>>testNthRootExactnessForHugeValue (in category 'tests - mathematical functions') -----
+ testNthRootExactnessForHugeValue
+ self assert: ((10 raisedTo: 600) nthRoot: 300) classAndValueEquals: 100.
+ self assert: ((10 raisedTo: 600) + 1 nthRoot: 300) classAndValueEquals: 100.0!
Item was added:
+ ----- Method: IntegerTest>>testNthRootImmuneToDoubleRounding (in category 'tests - mathematical functions') -----
+ testNthRootImmuneToDoubleRounding
+ "Use a specially crafted number for causing double rounding.
+ Solution is 10...01.1 - verySmallQuantity.
+ Where verySmallQuantity is approximately 1/53/(1<<53).
+ If the verySmallQuantity is not taken into account, then solution is rounded to 10....010"
+ | exponent crafted root highPrecisionRoot |
+ exponent := 4.
+ crafted := (1 << Float precision + 3 raisedTo: exponent) - 1.
+ root := crafted nthRoot: exponent.
+ highPrecisionRoot := (crafted << (exponent squared * Float precision * 4) nthRootRounded: exponent) / (1 << (exponent * Float precision * 4)).
+ self assert: (root asFraction - highPrecisionRoot) abs < (root predecessor asFraction - highPrecisionRoot) abs.
+
+ "Same with the other sign.
+ Solution is 10...00.1 + verySmallQuantity."
+ crafted := (1 << Float precision + 1 raisedTo: exponent) + 1.
+ root := crafted nthRoot: exponent.
+ highPrecisionRoot := (crafted << (exponent squared * Float precision * 4) nthRootRounded: exponent) / (1 << (exponent * Float precision * 4)).
+ self assert: (root asFraction - highPrecisionRoot) abs < (root successor asFraction - highPrecisionRoot) abs.!
More information about the Packages
mailing list