Hacker News new | past | comments | ask | show | jobs | submit login

But how often are people using decimal types to do that? Most of the uses I could see this type being used for - currency, percent scaling, datetimes, audio/video codec frame rates - all are basically fixed point operations. Anything involving powers of 80/81 would probably need bigint based rationals anyways.

Actually if you had an int64 type which was scaled by flicks, that'd give you quite a lot of latitude for most day to day stuff.

https://en.m.wikipedia.org/wiki/Flick_(time)




Yeah, fixed point is different from rational, and all those examples you gave sound to me like fixed point. And that can be implemented efficiently without dedicated hardware support: the denominator is fixed, and you store the numerator as an integer.

A 1/3 off discount on a $10 item is $6.67 (or $6.66 if rounding in the customer's favor), not $10/3.

(Except datetime, did you mean timestamp? A timestamp is an instant in time, and it often makes sense to store it in high precision because you're saying exactly when something happened. A datetime is for communicating between humans who are using some particular calendar; it rarely makes sense to have more than minute precision.)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: