numbers in 4.10 pasted by andyjpb on Fri Jul 3 16:18:25 2015

Inside a module:

-----
; https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
; 64-bit, signed, two's complement integer
; With a little help from protobuf's encoding.scm
(define long (bind (repeated item 8)
                   (lambda (x)
                     (result
                       (let ((n (apply bytes->number x)))
                         (if (positive? (- n #x8000000000000000))
                           (- n #x10000000000000000)
                           n))))))
-----

Returns:

-8.74244882465208e+18 outside the module in csi, even if I do (use numbers the-module).

However,

-----
(define (bytes->number . bytes)
  (let loop ((int   0)
             (bytes bytes))
    (if (null? bytes)
      int
      (loop
        (bitwise-ior
          (arithmetic-shift int 8)
          (char->integer (car bytes)))
        (cdr bytes)))))


; https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
; 64-bit, signed, two's complement integer
; With a little help from protobuf's encoding.scm
(define long (bind (repeated item 8)
                   (lambda (x)
                     (result
                       (let ((n (apply bytes->number x)))
                         (if (positive? (- n #x8000000000000000))
                           (- n #x10000000000000000)
                           n) n)))))
-----

i.e. return the un-arithmetised number returns:

9704295249057472651 outside the module.

And doing (- 9704295249057472651 #x10000000000000000) in csi gives:

-8742448824652078965

no title added by anonymous on Fri Jul 3 16:19:07 2015

(The module itself has "(use numbers)")