Unsigned long to double and back

2022-12-01 Thread david32...@btinternet.com david32...@btinternet.com
On Sun Nov 6 00:17:19 UTC 2022 Johannes Kuhn wrote: ... In particular, I would love to see the following methods added*: - double Double.fromUnsignedLong(long i) - long Double.toUnsignedLong(double d) - float Float.fromUnsignedLong(long i) - long Float.toUnsignedLong(float f) ... The method

Re: Unsigned long to double and back

2022-11-11 Thread David Lloyd
i > > -- > > *From: *"David Lloyd" > *To: *"Johannes Kuhn" > *Cc: *"core-libs-dev" > *Sent: *Friday, November 11, 2022 3:38:31 PM > *Subject: *Re: Unsigned long to double and back > > Well, I typed this out from

Re: Unsigned long to double and back

2022-11-11 Thread Remi Forax
"Johannes Kuhn" > Cc: "core-libs-dev" > Sent: Friday, November 11, 2022 3:38:31 PM > Subject: Re: Unsigned long to double and back > Well, I typed this out from memory so there's an error, of course. `(tmp & 1)` > should be `(input & 1)`. > On Fri, No

Re: Unsigned long to double and back

2022-11-11 Thread David Lloyd
Well, I typed this out from memory so there's an error, of course. `(tmp & 1)` should be `(input & 1)`. On Fri, Nov 11, 2022 at 8:31 AM David Lloyd wrote: > I encountered this issue as well; for now I'm using the following > transformation: > > long tmp = input >>> 1; > double output = ((double)

Re: Unsigned long to double and back

2022-11-11 Thread David Lloyd
I encountered this issue as well; for now I'm using the following transformation: long tmp = input >>> 1; double output = ((double) tmp) * 2.0 + (tmp & 1); I... *think* it's correct but I'm not 100% sure and have a long-standing TODO to try and figure it out... On Sat, Nov 5, 2022 at 7:17 PM Joh

Unsigned long to double and back

2022-11-05 Thread Johannes Kuhn
When I tried to implement an WASM transpiler, I noticed some missing conversion methods from unsigned types to floating point, for example from unsigned long to a double. For the meaning of unsigned long, see Long.toUnsignedString(long i). Converting between unsigned long and floating point is