Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How was non-decimal money represented in software?

A lot of the answers to the questions about the accuracy of float and double recommend the use of decimal for monetary amounts. This works because today all currencies are decimal except MGA and MRO, and those have subunits of 1/5 so are still decimal-friendly.

But what about the software used in U.S. stock markets when prices were in 1/16ths of dollar? The accuracy of binary data types wouldn't have been an issue, right?

Going further back, how did pre-1971 British accounting software deal with pounds, shillings, and pence? Did their versions of COBOL have a special PIC clause for it? Were all amounts stored in pence? How was decimalisation handled?

like image 933
dan04 Avatar asked Jun 13 '10 06:06

dan04


People also ask

What currency does not use decimals?

Today, only two countries have non-decimal currencies: Mauritania, where 1 ouguiya = 5 khoums, and Madagascar, where 1 ariary = 5 iraimbilanja.

Do all currencies use decimals?

Most currencies have two decimals. Some currencies do not have decimals, and some have three decimals. For example: 10 GBP: GBP has two decimals, so in minor units submit an amount of 1000.

Do all currencies have 2 decimal places?

Not all currencies across the world have two decimal places. Some have zero decimal places (e.g. Japanese yen), some have three decimal places (the dinar in many countries), and in Madagascar the minor unit is one fifth of the major unit so currency would be written to one decimal place.

What is a decimal currency system?

/ˌdes.ɪ.məl ˈkɝː. ən.si/ a money system in which a smaller unit can be multiplied by ten or a 100 to make up a bigger unit: The UK and the US both have decimal currencies. Currencies.


1 Answers

PL/I had a type specifically for British currency - I don't know about COBOL. The British currency at one time incorporated farthings, or a quarter of a penny; I'm not sure though that computers had to deal with those, just with half pennies or ha'pennies.

Accurate accounting usually uses special types - representing decimals exactly. The new IEEE 754 has support for floating-point decimals, and some chips (notably IBM pSeries) have such support in hardware.

like image 64
Jonathan Leffler Avatar answered Nov 13 '22 02:11

Jonathan Leffler