Skip to content
This repository has been archived by the owner on Feb 27, 2020. It is now read-only.

notes / questions #1

Open
timotheecour opened this issue Feb 9, 2020 · 4 comments
Open

notes / questions #1

timotheecour opened this issue Feb 9, 2020 · 4 comments

Comments

@timotheecour
Copy link
Contributor

timotheecour commented Feb 9, 2020

consider rename to nim-ryu or similar

the nimble package name can/should stay ryu, but the github repo name should probably be changed to nim-ryu otherwise it increases chances of conflict with original https://github.com/ulfjack/ryu (eg for users having forks + your package), since your package is not a fork but a port

thanks for working on this btw

status

looks good so far! not quite correct yet wrt nim-lang/Nim#13196, eg:

  let x = 0.12345678901234567890123456789
  let j = %* x
  let y = (j.getFloat.f2s).parseJson().getFloat()
  echo x.f2s # 1.2345679e-1
  echo y.f2s # 1.2345679e-1
  doAssert x == y # currently fails

links

As I understand it, the fact that short numbers perform worse is an inherent aspect of the algorithm. Dtoa goes left to right and avoids generating too many noise digits, so the performance is better on short numbers as reflected in the table. Ryū generates an exact representation and then goes right to left removing noise digits, so the performance is better on the longest numbers. The Ryū benchmarks all focus on a random distribution of numbers, and those have on average a lot of digits.

@timotheecour timotheecour changed the title consider rename to nim-ryu or similar notes / questions Feb 10, 2020
@disruptek
Copy link
Owner

That's a good link, but it's also as expected, right? You don't use this to store a 4-digit decimal, right? What do you use? A string.

@planetis-m
Copy link

Also there is already a nim port https://github.com/LemonBoy/dtoa.nim

@timotheecour
Copy link
Contributor Author

timotheecour commented Feb 13, 2020

dtoa is a different algorithm (and IIUC not expected to produce the most compact stringification) but would be a great thing to compare against (eg for performance)

@disruptek
Copy link
Owner

@alaviss is writing a nimish version of Ryu that should deprecate this repo. So, the goal of this effort is to flesh out tests and benchmarks so that we can vet future implementations. I expect that the next implementation will be much friendlier to inclusion in the stdlib, for example.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants