[Info-vax] New VSI Roadmap (yipee!)
Scott Dorsey
kludge at panix.com
Tue Mar 3 11:08:37 EST 2015
JF Mezei <jfmezei.spamnot at vaxination.ca> wrote:
>On 15-03-02 17:44, Scott Dorsey wrote:
>
>> When that is the case, you use integers for cents, then you use input and
>> output routines that deal with the decimal point.
>
>
>I have not thought about this fully but...
>
>if you have
>
>internet total_cents
>float output_number
>
>you do all the math with total_cents.
>
>But when it comes to display, you do :
> output_number = total_cents /100.0
>
>
>And then you print the output_number with a format that allows only 2
>decimals.
>
>Would this work in every circumstance and be totally safe, or would
>there be cases where the displayed number would be off ?
This is how it is done when there are no BCD types... sometimes the compiler
does it for you, sometimes you have to do it yourself.
>BTW, for SWIFT financial transfers, if I recall correctly, it had
>support for at least 4 or more decimals for currency amounts. This was
>to allow the specification of say 100,000 widgets priced at USD $1.1234
>each based on current exchange rates.
If you have to deal with mils or tenths of a mil.... then you need to store
those instead of cents.
--scott
--
"C'est un Nagra. C'est suisse, et tres, tres precis."
More information about the Info-vax
mailing list