M2 icon indicating copy to clipboard operation
M2 copied to clipboard

Fix realPart/imaginaryPart/conjugate bugs

Open d-torrance opened this issue 1 year ago • 0 comments

realPart and imaginaryPart expected one of the Number types defined in the interpreter, so failed when given one of the Number types defined at top-level (Constant, InfiniteNumber, IndeterminateNumber).

conjugate assumed that every non-CC Number object was real, and so gave the wrong output when given ii, which is complex but is a Constant object.

We also update the docs and add unit tests.

Before

i1 : realPart ii
stdio:2:8:(3): error: expected a number

i2 : imaginaryPart ii
stdio:3:13:(3): error: expected a number

i3 : conjugate ii

o3 = ii

o3 : Constant

After

i1 : realPart ii

o1 = 0

o1 : RR (of precision 53)

i2 : imaginaryPart ii

o2 = 1

o2 : RR (of precision 53)

i3 : conjugate ii

o3 = -ii

o3 : CC (of precision 53)

d-torrance avatar Oct 03 '24 11:10 d-torrance