Skip to content

Commit 946eebb

Browse files
Merge pull request #69 from SergeStinckwich/development
PMComplex miss a signBit method (used in Pharo) Fix
2 parents d0acf00 + 72ef268 commit 946eebb

File tree

3 files changed

+43
-23
lines changed

3 files changed

+43
-23
lines changed

src/Math-Complex/PMComplex.class.st

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,11 @@ PMComplex >> sign [
650650
^ real sign
651651
]
652652

653+
{ #category : #testing }
654+
PMComplex >> signBit [
655+
^self real signBit
656+
]
657+
653658
{ #category : #'mathematical functions' }
654659
PMComplex >> sin [
655660
"Answer receiver's sine."

src/Math-Complex/PMComplex.extension.st

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ PMComplex >> productWithVector: aVector [
1717
^ aVector collect: [ :each | each * self ]
1818
]
1919

20+
{ #category : #'*Math-Complex' }
21+
PMComplex class >> random [
22+
"Answers a random number with abs between 0 and 1."
23+
24+
^ self abs: 1.0 random arg: 2 * Float pi random
25+
]
26+
2027
{ #category : #'*Math-Complex' }
2128
PMComplex >> random [
2229
"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."
2330
^ self class random * self
2431

2532
]
2633

27-
{ #category : #'*Math-Complex' }
28-
PMComplex classSide >> random [
29-
"Answers a random number with abs between 0 and 1."
30-
31-
^ self abs: 1.0 random arg: 2 * Float pi random
32-
]
33-
3434
{ #category : #'*Math-Complex' }
3535
PMComplex >> subtractToPolynomial: aPolynomial [
3636
^ aPolynomial addNumber: self negated

src/Math-Tests-ArbitraryPrecisionFloat/ArbitraryPrecisionFloatTest.class.st

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ Class {
1616
#category : 'Math-Tests-ArbitraryPrecisionFloat'
1717
}
1818

19+
{ #category : #accessing }
20+
ArbitraryPrecisionFloatTest class >> defaultTimeLimit [
21+
^60 seconds
22+
]
23+
1924
{ #category : #private }
2025
ArbitraryPrecisionFloatTest >> checkDoublePrecision: y forFunction: func nBits: n [
2126
"Check that doubling the precision, then rounding would lead to the same result"
@@ -645,27 +650,37 @@ ArbitraryPrecisionFloatTest >> testPositive [
645650

646651
{ #category : #'testing-converting' }
647652
ArbitraryPrecisionFloatTest >> testPrintAndEvaluate [
648-
<timeout: 50 "seconds">
653+
"seconds"
654+
655+
<timeout: 50>
649656
| emax emin leadingOne significands |
650-
significands := 0 to: 1<<10-1.
651-
leadingOne := 1<<10.
657+
significands := 0 to: (1 << 10) - 1.
658+
leadingOne := 1 << 10.
652659
emin := -14.
653660
emax := 15.
654-
661+
655662
"Test all normal finite half precision float"
656-
emin to: emax do: [:e |
657-
significands do: [:s |
658-
| f |
659-
f := (leadingOne + s asArbitraryPrecisionFloatNumBits: 11) timesTwoPower: e - 10.
660-
self assert: (Compiler evaluate: f storeString) = f.
661-
self assert: (Compiler evaluate: f printString) = f.]].
662-
663+
emin to: emax do: [ :e |
664+
significands
665+
do: [ :s |
666+
| f |
667+
f := (leadingOne + s asArbitraryPrecisionFloatNumBits: 11)
668+
timesTwoPower: e - 10.
669+
self
670+
assert: (Smalltalk compiler evaluate: f storeString)
671+
equals: f.
672+
self
673+
assert: (Smalltalk compiler evaluate: f printString)
674+
equals: f ] ].
675+
663676
"Test all subnormal finite half precision float"
664-
significands do: [:s |
665-
| f |
666-
f := (s asArbitraryPrecisionFloatNumBits: s highBit) timesTwoPower: emin - 10.
667-
self assert: (Compiler evaluate: f storeString) = f.
668-
self assert: (Compiler evaluate: f printString) = f].
677+
significands
678+
do: [ :s |
679+
| f |
680+
f := (s asArbitraryPrecisionFloatNumBits: s highBit)
681+
timesTwoPower: emin - 10.
682+
self assert: (Smalltalk compiler evaluate: f storeString) equals: f.
683+
self assert: (Smalltalk compiler evaluate: f printString) equals: f ]
669684
]
670685

671686
{ #category : #'testing-arithmetic' }

0 commit comments

Comments
 (0)