Giter VIP home page Giter VIP logo

Comments (7)

clyring avatar clyring commented on June 21, 2024

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.

BebeSparkelSparkel avatar BebeSparkelSparkel commented on June 21, 2024

This is much more flexible. Thank you for the idea.

from bytestring.

BebeSparkelSparkel avatar BebeSparkelSparkel commented on June 21, 2024

@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.

BebeSparkelSparkel avatar BebeSparkelSparkel commented on June 21, 2024

This seems to be going beyond the intended capabilities of the intended formatting capabilities.

from bytestring.

clyring avatar clyring commented on June 21, 2024

@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.

BebeSparkelSparkel avatar BebeSparkelSparkel commented on June 21, 2024

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.

BebeSparkelSparkel avatar BebeSparkelSparkel commented on June 21, 2024

Also, a problem with your proposed approach. FStandard does not use this so formatFloating cannot return (Builder, Int).

from bytestring.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.