Comments (7)
Perhaps the way to support this is a higher-order interface that takes displayExponent :: Int -> Builder
. Then you could write such a function that prints an exponent of 0
as E+000
or one that dislays it as e0
. That seems a bit less nasty than having a bunch of flags for 'is e
capitalized' and 'should a + be written for positive exponents' and 'should the exponent be zero-padded'.
Another idea is to provide a function of type Double -> (Builder, Int)
where the Builder
prints just the mantissa and the Int
is the exponent.
from bytestring.
This is much more flexible. Thank you for the idea.
from bytestring.
@clyring I have been unable to make your suggestion performant. I have tried several ways but am consistently getting results that are 150-300% slower. Could you make some recommendations on how modify the overhaul-realfloat branch to implement your suggested change?
from bytestring.
This seems to be going beyond the intended capabilities of the intended formatting capabilities.
from bytestring.
@clyring I have been unable to make your suggestion performant. I have tried several ways but am consistently getting results that are 150-300% slower. Could you make some recommendations on how modify the overhaul-realfloat branch to implement your suggested change?
I'd expect there is a practical way to get an appropriately general interface for this without requiring such a performance hit. Perhaps using BoundedPrim
instead of Builder
helps? Or maybe we need to get the right amount of inlining to happen? But I don't have the spare focus to dig into this yet.
But it would be nice to provide an interface flexible enough to support this. Let's leave the issue open for now.
from bytestring.
I have been thinking about this and perhaps the most flexible option for printing both the mantissa and exponent would be to extract F2S, D2S, and their dependencies that calculate the digits word and exponent integer to a new package. This would allow the most flexibility for custom printing of the mantissa and exponent and would allow other text types to use it for their own printing implementations.
from bytestring.
Also, a problem with your proposed approach. FStandard
does not use this so formatFloating
cannot return (Builder, Int)
.
from bytestring.
Related Issues (20)
- Compatibility with GHC's JavaScript backend HOT 1
- Overhaul Data.ByteString.Builder.RealFloat HOT 5
- Float and Double standard with precision 0 outputs incorrectly HOT 2
- Positive and Negative Zero Print Incorrect Precision
- Guidelines for using with WriterT HOT 2
- Faster Printing for Known Normal and Subnormal IEEE754 Floating Point Values
- Broken links in haddocks of `ShortByteString` HOT 1
- Audit `foreign import ccall` types
- Drop support for GHCs older than 8.4 HOT 1
- Add a splice of ShortByteString builder
- 0.12.1.0 fails to build on darwin aarch64 with GHC-8.10.7 HOT 13
- Create strict bytestrings from FixedPrim with zero copy HOT 6
- Lazy `zip` is stricter than expected
- unsafeUseAsCString(Len) may return a NULL pointer. HOT 9
- Document that `Data.ByteString.Lazy.appendFile` is not threadsafe.
- Eq and Ord for Builder
- Offer conversion with `Natural`. HOT 1
- Fixed Point Rounding HOT 2
- Store a `State# RealWorld` in the ByteString HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bytestring.