0

Is there a way to get the functionality of c++'s std::nextafter in Elm? I'm happy to use an external javascript function if that's the only way.

For background, std::nextafter is a function taking a floating point number and returning the next representable floating point number by size.

derekdreery
  • 3,860
  • 4
  • 29
  • 38

1 Answers1

2

As for X... nextafter library provides this functionality, and I doubt very much whether Elm would have anything built in... it's just not a frequently useful procedure.

As for Y, honestly, you're not going about this the right way. The reason that nextafter wasn't added until C++11 is that it's not widely useful. In particular, if you plan to use it to give some interface a number which is strictly greater than a given number, while remaining as close to it as possible, prepare for disappointment. Many such interfaces will do initial operations which can have the effect of abnegating that strict ordering. And if you plan to iterate over all the numbers in some range... keep in mind that there are about 4 billion billion of them between 0 and 1.

Sneftel
  • 40,271
  • 12
  • 71
  • 104
  • There are internal calculations in svg implementations that lose more information than this, so I need to find another solution. Thanks for the answer though! – derekdreery Dec 22 '17 at 19:39