4 ms·
I suppose it should have gone like this: * You need to unmarshal hardware floats * You visit Hackage, and use the IEEE754 package. http://hackage.haskell.org/
by dons 13y ago
I suppose it should have gone like this:
* You need to unmarshal hardware floats
* You visit Hackage, and use the IEEE754 package. http://hackage.haskell.org/package/data-binary-ieee754 http://hackage.haskell.org/package/data-binary-ieee754
If that is fast enough, you stop. You are done.
* IEEE754 is too slow for some reason, so you decide to do your own unsafeCoerce of bytestring
* You look at the source for IEE754 and decide to marshal memory yourself: http://hackage.haskell.org/packages/archive/data-binary-ieee754/0.4.4/doc/html/src/Data-Binary-IEEE754.html#wordToDouble http://hackage.haskell.org/packages/archive/data-binary-ieee...
* You read the bytestring package docs: http://hackage.haskell.org/packages/archive/bytestring/0.9.1.4/doc/html/Data-ByteString-Internal.html http://hackage.haskell.org/packages/archive/bytestring/0.9.1... and pay attention to the "unsafe" functions that cast raw pointers.
* That lets you re-implement the IEEE754 package your own way
The mistake here was not using the highly-optimized existing library - http://hackage.haskell.org/packages/archive/data-binary-ieee754/0.4.4/doc/html/src/Data-Binary-IEEE754.html#wordToDouble http://hackage.haskell.org/packages/archive/data-binary-ieee... - which already does the correct thing. You jumped straight to "have to roll my own low level binary parsing" and then started a reddit thread instead. None of that was necessary.
- zvrba 13y ago> "have to roll my own low level binary parsing" But that was the whole point from the beginning! Find out how can I do it myself. > You read the bytestring package docs: I repeat: the Internal module isn't listed in the locally installed documentation, and the link on Hackage is broken. Do I really need to produce for you the two top-level links where I was looking for the documentation of Internal?