diff --git a/src/Math-Complex/PMComplex.class.st b/src/Math-Complex/PMComplex.class.st index e61e6de12..edd8fc131 100644 --- a/src/Math-Complex/PMComplex.class.st +++ b/src/Math-Complex/PMComplex.class.st @@ -650,6 +650,11 @@ PMComplex >> sign [ ^ real sign ] +{ #category : #testing } +PMComplex >> signBit [ +^self real signBit +] + { #category : #'mathematical functions' } PMComplex >> sin [ "Answer receiver's sine." diff --git a/src/Math-Complex/PMComplex.extension.st b/src/Math-Complex/PMComplex.extension.st index e55dcb5cd..efe456833 100644 --- a/src/Math-Complex/PMComplex.extension.st +++ b/src/Math-Complex/PMComplex.extension.st @@ -17,6 +17,13 @@ PMComplex >> productWithVector: aVector [ ^ aVector collect: [ :each | each * self ] ] +{ #category : #'*Math-Complex' } +PMComplex class >> random [ + "Answers a random number with abs between 0 and 1." + + ^ self abs: 1.0 random arg: 2 * Float pi random +] + { #category : #'*Math-Complex' } PMComplex >> random [ "analog to Number>>random. However, the only bound is that the abs of the produced complex is less than the length of the receive. The receiver effectively defines a disc within which the random element can be produced." @@ -24,13 +31,6 @@ PMComplex >> random [ ] -{ #category : #'*Math-Complex' } -PMComplex classSide >> random [ - "Answers a random number with abs between 0 and 1." - - ^ self abs: 1.0 random arg: 2 * Float pi random -] - { #category : #'*Math-Complex' } PMComplex >> subtractToPolynomial: aPolynomial [ ^ aPolynomial addNumber: self negated diff --git a/src/Math-Tests-ArbitraryPrecisionFloat/ArbitraryPrecisionFloatTest.class.st b/src/Math-Tests-ArbitraryPrecisionFloat/ArbitraryPrecisionFloatTest.class.st index 17a9aeea7..28297eb36 100644 --- a/src/Math-Tests-ArbitraryPrecisionFloat/ArbitraryPrecisionFloatTest.class.st +++ b/src/Math-Tests-ArbitraryPrecisionFloat/ArbitraryPrecisionFloatTest.class.st @@ -16,6 +16,11 @@ Class { #category : 'Math-Tests-ArbitraryPrecisionFloat' } +{ #category : #accessing } +ArbitraryPrecisionFloatTest class >> defaultTimeLimit [ + ^60 seconds +] + { #category : #private } ArbitraryPrecisionFloatTest >> checkDoublePrecision: y forFunction: func nBits: n [ "Check that doubling the precision, then rounding would lead to the same result" @@ -645,27 +650,37 @@ ArbitraryPrecisionFloatTest >> testPositive [ { #category : #'testing-converting' } ArbitraryPrecisionFloatTest >> testPrintAndEvaluate [ - + "seconds" + + | emax emin leadingOne significands | - significands := 0 to: 1<<10-1. - leadingOne := 1<<10. + significands := 0 to: (1 << 10) - 1. + leadingOne := 1 << 10. emin := -14. emax := 15. - + "Test all normal finite half precision float" - emin to: emax do: [:e | - significands do: [:s | - | f | - f := (leadingOne + s asArbitraryPrecisionFloatNumBits: 11) timesTwoPower: e - 10. - self assert: (Compiler evaluate: f storeString) = f. - self assert: (Compiler evaluate: f printString) = f.]]. - + emin to: emax do: [ :e | + significands + do: [ :s | + | f | + f := (leadingOne + s asArbitraryPrecisionFloatNumBits: 11) + timesTwoPower: e - 10. + self + assert: (Smalltalk compiler evaluate: f storeString) + equals: f. + self + assert: (Smalltalk compiler evaluate: f printString) + equals: f ] ]. + "Test all subnormal finite half precision float" - significands do: [:s | - | f | - f := (s asArbitraryPrecisionFloatNumBits: s highBit) timesTwoPower: emin - 10. - self assert: (Compiler evaluate: f storeString) = f. - self assert: (Compiler evaluate: f printString) = f]. + significands + do: [ :s | + | f | + f := (s asArbitraryPrecisionFloatNumBits: s highBit) + timesTwoPower: emin - 10. + self assert: (Smalltalk compiler evaluate: f storeString) equals: f. + self assert: (Smalltalk compiler evaluate: f printString) equals: f ] ] { #category : #'testing-arithmetic' }