[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: L66@psuvm.psu.edu*Subject*: Re: Help needed; Number and Precision Problem*From*: cassels (Robert A. Cassels)*Date*: Mon, 27 Jan 92 10:24:31 EDT*Cc*: info-mcl

> To: info-mcl > From: L66@psuvm.psu.edu > > Hi, Netters. I need your help. I am using MCL 1.3.2. > My question is how can I save just two digits after decimal point. > (float 1/3) returns 0.3333333333333. However, I want keep just 0.33 instead of > whole precision. (float (/ num1 num2)) ===> x.xx is the form I want. > Any help will be welcomed. Many thanks in advance. L66@psuvm.psu.edu What are you *really* trying to do? If you simply want to print answers with 2 decimal places, use the "~F" or "~$" format directives. If you want to do arithmetic where all results are kept to 2 decimal places, you'll have to write your own package of routines. But that's easy -- just keep everything as integer cents. The only hard part is figuring out how you want to round the results of multiplication and division. (Doing the rounding is easy once you know what you want.) BTW, it's quite likely that you *don't* want to use floating-point numbers. If you can give me a better idea of what you're trying to accomplish, perhaps I can be of more help.

- Prev by Date:
**Patch beyond b1p3?** - Next by Date:
**Re: Help needed; Number and Precision Problem** - Previous by thread:
**Re: Help needed; Number and Precision Problem** - Next by thread:
**Re: Help needed; Number and Precision Problem** - Index(es):