Xavier Noria
7223c62b7310e164eb79c740188abbda?d=retro
Ranked 49 in Phase 1 with 51 unique views, 14 counted upvotes and 9 counted downvotes

I See Your 127.32+, A Tale of Rationals

Money, be careful with money.

While developing a brand new website for online betting I found the requirements related to the flow of money were just not possible to implement with traditional datatypes. There were fundamental features that no matter your precision, would just not work correctly.

After reflecting on the feature set, we ended up resorting to fractions. In this talk I'll explain how we integrated rationals in the full stack, from JavaScript down to PostgreSQL, going via Active Record. An interesting journey that ends with all cents under control, and me sleeping very well at night.


Previous Next

Suggestions

  • D87dddeb300217e6c6574f5ffae220be?d=retro Nikos Dimitrakopoulos suggested 8 months ago

    Interesting and always relevant topic, and I agree with Fotos, about the title :)

  • The proposal author responded 8 months ago

    Glad you find it interesting! It certainly requires discipline.

    Yeah, it is going to be more radical. The money gem uses BigDecimal for infinite precision in Ruby, while this solution uses actual rational numbers across all layers. No float of any kind is involved.

  • 415fe6ee69c09802ce8329e2b1a1c5e6?d=retro Vassilis Rizopoulos suggested 8 months ago

    I really like this type of subjects I must say. Perennial problems like the one where infinite precision is required in a system with finite significant places and the pitfalls this brings especially when dealing with money are not "solved". Ruby's automagical number handling obscures the complexity and there are some nasty nasty pitfalls. Would definitely like to watch this.

  • 3c7964e731bc7da3786195d7ac264209?d=retro Fotos Georgiadis suggested 8 months ago

    Having dealt with money in an international setting, I say this is a really nice topic. In general handling I18n issues in large applications is difficult, needs experience and lots of discipline.

    I guess this is going to talk a bit about the money gem, right? Or are you going to show something different / more radical?

    Tongue in cheek I propose you change the presentation title to ""I see your $127.32 and raise you 20,89 €" :-)