Giter Site home page Giter Site logo

formattable's Introduction

formattable

A business-quality formatting package with reified formats for multiple data types

This package provides excellent support for formatting numbers including the following configurable features:

  • units (thousands, millions, percent, etc)
  • prefixes ($, £, etc)
  • suffixes (%, ¢, etc)
  • decimal separators
  • thousands separators
  • styles for fixed decimal notation, scientific notation, and SI prefixes
  • specify precision as number of decimal places or sig figs
  • different styles of negative numbers

Examples

  • runFormat (intFmt { _nfStyle = SIStyle }) (225142.3 :: Double) == "225k"

See the test suite for more examples.

formattable's People

Contributors

michaelxavier avatar mightybyte avatar ozataman avatar portnov avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

prillan portnov

formattable's Issues

Release on hackage?

Could you please make one? The current one is from 2015 and pulls an old data-default-class.

behavior diverges from double-conversion

@ozataman Maybe you can weigh in here. I don't actually know what the correct behavior is here and my work on this project has been janitorial.

I've added a failing test here. If you check out with the stack branch and run stack test it should fail. This case was discovered by quickcheck. It looks like we used to depend on double-conversion but dropped the dep.

We added a quickcheck test that asserted that for all inputs we'd produce the same formatted number with our own code that we would if we used double-conversion's exponential formatter toExponential . fromMaybe (-1) and fixed formatter toFixed . fromMaybe (-1). However, it turns out double-conversion rounds up but we don't. Given the number 1.5069003e-316 we produce $1e-322% but double-conversion produces $2e-322%. I tried the exact same test but with 1.4069003e-316 and both synced up to $1e-322%, so it looks like rounding is going on. It isn't clear to me which library is right here.

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.