wraithm / lendingclub

Haskell API bindings to the LendingClub marketplace API
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Money as Double? #1

Open DiegoNolan opened 9 years ago

DiegoNolan commented 9 years ago

Why is money not fixed point? Haskell has Rational.

wraithm commented 9 years ago

The reason why I did this is that the Lending Club API uses floating point, at least superficially (eg. https://www.lendingclub.com/developers/summary.action). You caught me. I was lazy.

You're absolutely right that it makes more sense to use fixed point instead. Something like scientific might be a good candidate.

What do you think Integer, scientific, something else? I'm very open to other suggestions.

On Mon, Sep 7, 2015 at 11:38 PM, Nolan Sandberg notifications@github.com wrote:

Why is money not fixed point? Haskell has Rational.

— Reply to this email directly or view it on GitHub https://github.com/WraithM/lendingclub/issues/1.

dmjio commented 9 years ago

Scientific or Decimal, probably

Sent from my iPhone

On Sep 7, 2015, at 11:57 PM, Matthew Wraith notifications@github.com wrote:

The reason why I did this is that the Lending Club API uses floating point, at least superficially (eg. https://www.lendingclub.com/developers/summary.action). You caught me. I was lazy.

You're absolutely right that it makes more sense to use fixed point instead. Something like scientific might be a good candidate.

What do you think Integer, scientific, something else? I'm very open to other suggestions.

On Mon, Sep 7, 2015 at 11:38 PM, Nolan Sandberg notifications@github.com wrote:

Why is money not fixed point? Haskell has Rational.

— Reply to this email directly or view it on GitHub https://github.com/WraithM/lendingclub/issues/1.

— Reply to this email directly or view it on GitHub.

DiegoNolan commented 9 years ago

I'm wondering if it is necessary though. If we are using application/json I don't know if it matters since in javascript all numbers are represented as doubles. I guess when we end of doing arithmetic operations on the results we get from the API it may matter.

wraithm commented 9 years ago

Yeah, you're exactly where I was thinking when I wrote this thing. You're exactly right that lending club is using doubles for the json, and that's why I used doubles. Again, you're right that you get precision issues when you do arithmetic on that data using this library.

I don't know anything about Decimal. My favorite would probably be using Integer. On Sep 8, 2015 12:09, "Nolan Sandberg" notifications@github.com wrote:

I'm wondering if it is necessary though. If we are using application/json I don't know if it matters since in javascript all numbers are represented as doubles. I guess when we end of doing arithmetic operations on the results we get from the API it may matter.

— Reply to this email directly or view it on GitHub https://github.com/WraithM/lendingclub/issues/1#issuecomment-138636614.