4 ms·
Easy, either implement a decimal type (4 fractional digits) as most programming languages have them implemented by users. or multiply by 10000 then do your calc
by Yaa101 7y ago
Easy, either implement a decimal type (4 fractional digits) as most programming languages have them implemented by users.
or multiply by 10000 then do your calculation and then divide by 10000 again.
I used a decimal type for the administration program I coded.
- dragonwriter 7y ago> Easy, either implement a decimal type (4 fractional digits) as most programming languages have them implemented by users. C#, Ruby, Python, and Java, at least, among industrially popular languages all provide a fixed and/or arbitrary precision decimal type in either the core language or stdlib. Lower level languages sometimes don't, and JavaScript, among higher-level popular languages, notably does not.
- geofft 7y ago> Easy, either implement a decimal type Great, how do you become confident that your hand-rolled decimal type is less buggy than the known hazards of using floating-point?
- jdlshore 7y agoIf you’ve never done something like this, you might want to try it. It’s a nice simple programming exercise and the basic version, with tests, will take less than an evening.