5 ms·
Would it be better to store the integer and fractional parts separately, or mantissa and exponent?
by sp332 6y ago
Would it be better to store the integer and fractional parts separately, or mantissa and exponent?
- InfiniteRand 6y agoI think that makes sense, given the room for confusion Just curious does any country use fractions of a bill other then 1/100 (ie cents)
- Smaug123 6y agoThe USA does, for example. There are ten mill in a cent. Apparently Tunisia even has five-mill coins in circulation. https://en.wikipedia.org/wiki/Mill_(currency) https://en.wikipedia.org/wiki/Mill_(currency)
- ceejayoz 6y agoUS gas stations frequently give prices in fractions of a cent. https://www.marketplace.org/2018/10/11/why-do-gas-prices-end-910-cent/ https://www.marketplace.org/2018/10/11/why-do-gas-prices-end...
- hyperdimension 6y agoMeh, from what I've seen so far, it's just so people see, e.g. 2.55 $/gal with the tiny nine in the corner, stop by and get charged 2.559 $/gal (essentially squeezing that last cent out of customers.) I'd be interested to hear if anyone else has seen any digit other than nine in the tenth-of-a-cent column though.
- toast0 6y agoI believe it's because gas prices are quoted with tax (which is unusual in the US), and there is a federal tax ending in 9 tenths of a cent. Probably lobbied by the small 9 marquee digit manufacturers of america.
- chrismorgan 6y agoAustralian fuel prices are listed in cents to one decimal place. >80% of the time the last digit is a nine, the rest of the time it’s most commonly a 5. I’ve seen other odd digits rarely, with even numbers just about unheard of. But what you actually pay will be rounded to the cent, or to the nearest 5¢ if you pay in cash. The whole concept involved here is called psychological pricing (https://en.wikipedia.org/wiki/Psychological_pricing https://en.wikipedia.org/wiki/Psychological_pricing). I wish it was illegal.
- Gwypaas 6y agoThis was posted here regarding some similar discussion a while ago. "Falsehoods programmers believe about prices" https://gist.github.com/rgs/6509585 https://gist.github.com/rgs/6509585
- jobigoud 6y agoYes 1/1000 is very commom in the Arab world.
- lanstin 6y agoIIRC correctly one country uses three digits in the less than one realm. This site https://www.localeplanet.com/icu/currency.html https://www.localeplanet.com/icu/currency.html has one three and even a four.
- dzhiurgis 6y agoFWIW Japan doesn’t use fractions - 1 yen is approx 1 US penny. Lunch is 300-500 yen.
- account42 6y agoGoing to add to the other comments that the "1" is not a bill in many currencies. For example the smallest Euro bill is 5€. Other currencies do not have a fractional part at all and use just one integer.
- chrismorgan 6y agoI’m just going to say “no”. If you don’t need to work with the value, store it in a string. If you do, use a proper decimal type. (Your question may then apply to the internals of the decimal type, but the point is that that should be transparent to the developer accessing the decimal value.)
- mrmonkeyman 6y agoJust store cents.