[SLUG] truncation in dc

From: Eben King (eben01@verizon.net)
Date: Fri Jul 06 2007 - 20:27:38 EDT


Anyone know how to truncate values in dc(1)? I RTFMed but couldn't find it.
For example:

If I set the precision to three places:

3k

and then calculate 1/3:

1 3/p
.333

It's correct. Supposing I only want one place to the right of the decimal
point:

1k

Adding 0 or 0.0, or multiplying by 1 or 1.0 won't work:

0+p
.333
0.0+p
.333

1*p
.333
1.0*p
.333

So how do I do it?

-- 
-eben   QebWenE01R@vTerYizUonI.nOetP   http://royalty.mine.nu:81

Every normal man must be tempted at times to spit upon his hands, hoist the black flag, and begin slitting throats. -- H.L. Mencken ----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 17:45:50 EDT