# Money type

Steven Schveighoffer schveiguy at gmail.com
Wed Jan 1 19:01:36 UTC 2020

```On 1/1/20 1:46 PM, IGotD- wrote:
> On Wednesday, 1 January 2020 at 18:16:01 UTC, Vitaly Livshic wrote:
>>  Thanks Steve, JN.
>>
>>  JN, BigInt is big integer. It cannot works with fractional numbers.
>> It is sadly, that wide-spread languages have no convinient money type.
>> This is abnormal.
>>  Hope, D will have fixed point type either as built-in type or library.
>
> That's probably because there is no standard how to deal with
> currencies. Think about Shillings and it goes 12 pence on one Shilling,
> weird stuff like that.

Well, that is just odd, as you then need 2 number systems, one with base
12, and one with base 10. Probably best to split that into a byte for
pence and some other integer for the shillings.

>
> Also why use fixed point? Why not have currency * 100 as there goes
> hundred cents in one base currency, for many currencies. To convert it
> back you just divide by 100 and you get the value and the cent value.
> Well * 100 is fixed point, but in computer land fixed point usually
> means some scale factor of the power of 2.

That is what I use. Fixed point with a factor of power of 10. In other
words, a fixed point number with 2 decimal places would be sufficient
for such currency. When doing math on such types, you just need to deal
with the underlying numbers, and it works fine.

-Steve
```