Rescript.float == Js.number == double?

This is a little pedantic, but I’m in a situation where the precision actually matters.

Are the following statements correct:

  1. rescript/float == js/number

  2. js/number == 64-bit double

  3. therefore rescript/float is really a 64-bit double, not a 32-bit float ?


(1) is correct and I just realized it’s not really documented on the ReScript website. Perhaps you could send a PR.

(2) is correct as per Number - JavaScript | MDN

Anyone else find this strange? I thought general convention was double == 64bit, float == 32bit

Not necessarily. ReScript mostly inherits its core system from OCaml, and in OCaml the float type is double-precision 64-bit: OCaml library : Float

In a very convenient coincidence, JavaScript’s Number type also happens to be defined as double-precision 64-bit, so the mapping between them is clean.

1 Like