Skip to content

approx vs print representation #4

@mgi

Description

@mgi

Hi,

In some code I'm writing I have to compare two creals. The code I'm using is the following:

(defun =r (a b precision)
  (let ((a (approx-r a precision))
        (b (approx-r b precision)))
    (unless (= a b) (break))
    (= a b)))

For some values, I end up in the debugger (with the break) but what is strange to me is that the backtrace (in sbcl BTW) shows me the following values for a and b:

Backtrace:
  0: (GEODESIC/TEST::=R +1.87802555827473610813... +1.87802555827473610814... 17)
      Locals:
        A = +1.87802555827473610813...
        A#1 = 246156
        B = +1.87802555827473610814...
        B#1 = 246157
        PRECISION = 17

So the printed representation of creals a and b seems to be the same up to the 19th decimal but their (approx-r x 17) are different.

I don't really understand creals internal representation so I don't know how to proceed from here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions