leventerkok / floatinghex Goto Github PK
View Code? Open in Web Editor NEWHexadecimal Floats for Haskell
License: Other
Hexadecimal Floats for Haskell
License: Other
Prelude Data.Numbers.FloatingHex> readHFloat "0xa0ff.f141a59a"
Nothing
> :set -XHexFloatLiterals
> toRational (0xa0ff.f141a59a :: Double) == 0xa0ff.f141a59a
True
It would be nice to support negative literals as well, like this:
[hf|-0x1p1]
Unfortunately, this is currently not possible due to a template-haskell shortcoming: There's no way to represent negative 0! (Or infinity for that matter.) See here: http://ghc.haskell.org/trac/ghc/ticket/13124
If TH is ever remedied to support proper floats, we can consider supporting negative literals as well.
Fyi, FloatingHex
needs an instance that was only added with TH 2.10 and later
Configuring component lib from FloatingHex-0.2...
Preprocessing library FloatingHex-0.2...
[1 of 1] Compiling Data.Numbers.FloatingHex ( Data/Numbers/FloatingHex.hs, /tmp/matrix-worker/1484424259/dist-newstyle/build/x86_64-linux/ghc-7.8.4/FloatingHex-0.2/build/Data/Numbers/FloatingHex.o )
Data/Numbers/FloatingHex.hs:92:30:
No instance for (TH.Lift Double) arising from a use of ‘TH.lift’
In the expression: TH.lift d
In a case alternative: Just d -> TH.lift d
In the expression:
case parseHexFloat s of {
Just d -> TH.lift d
Nothing
-> fail
$ "Invalid hexadecimal floating point number: |" ++ s ++ "|" }
I've already fixed up the meta-data on Hackage, e.g.
Currently showHFloat
is not compatible with printf
's %a
specifier. Using Haskell's floatToDigit
it should be possible to remedy this situation.
Would be nice if the parser read nan
/infinity
etc. as well; as special cases. Note that we have to use :%
in these cases to make sure reduction isn't done right away.
Due to rational requirement, the quasiquoter doesn't support negatives. But we should support it in the parse function, which should also be exported.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.