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

Re: bc - calculator



j-j@gmx.de wrote:
>This was really great and saved me hours of time. The problem is now,
>that I have to do the same thing with divisions, meaning 3/4 = 0.75. But
>bc spits out 3/4 => 0 and 4/3 => 1. Any Idea how I can change this
>behaviour to get the real results? Would save me some more hours...

You can use a command like 'scale=2' to bc to tell it to give you two
decimal places for floating-point arithmetic. So:

[cjw44@riva ~]$ bc --quiet
scale=2
3/4
.75
[cjw44@riva ~]$ 

HTH,

-- 
Colin Watson                                     [cjw44@flatline.org.uk]



Reply to: