Skip to content

Commit 9f3f82f

Browse files
Extracted the predicate to an intention revealing method.
1 parent 0d5e873 commit 9f3f82f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Math-Complex/PMComplex.class.st

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,12 @@ PMComplex >> isNumber [
557557
^ true
558558
]
559559

560+
{ #category : #'mathematical functions' }
561+
PMComplex >> isReal [
562+
563+
^ imaginary = 0 and: [ real >= 0 ]
564+
]
565+
560566
{ #category : #testing }
561567
PMComplex >> isZero [
562568
^ real isZero and: [imaginary isZero]
@@ -707,14 +713,14 @@ PMComplex >> sinh [
707713

708714
{ #category : #'mathematical functions' }
709715
PMComplex >> sqrt [
716+
710717
"Return the square root of the receiver with a positive imaginary part."
711718

712719
| u v |
713-
(imaginary = 0 and: [real >= 0])
714-
ifTrue: [^self class real: real sqrt imaginary: 0].
720+
self isReal ifTrue: [ ^ self class real: real sqrt imaginary: 0 ].
715721
v := (self abs - real / 2) sqrt.
716722
u := imaginary / 2 / v.
717-
^self class real: u imaginary: v
723+
^ self class real: u imaginary: v
718724
]
719725

720726
{ #category : #'mathematical functions' }

0 commit comments

Comments
 (0)