On Sat, 7 Jul 2007, ronan wrote:
> Eben King wrote:
>> 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?
>>
> Before doing your math, send "1 k" to set the precision to 1 decimal place.
> For example:
>
> 1 k 1 3/p
>
> yields:
> .3
I think that sets the intermediate precision as well as the
output precision. That is generally undesirable, and can only be worked
around with careful equation design. For example:
1k 41 90 / 90 * p
36.0
8k 41 90 / 90 * p
40.99999950
-- -eben QebWenE01R@vTerYizUonI.nOetP http://royalty.mine.nu:81 ARIES: The look on your face will be priceless when you find that 40lb watermelon in your colon. Trade toothbrushes with an albino dwarf, then give a hickey to Meryl Streep. -- Weird Al, _Your Horoscope for Today_ ----------------------------------------------------------------------- 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:46:27 EDT