FAQ (bc-1.07) | : | FAQ (bc-1.07.1) | ||
---|---|---|---|---|

skipping to change at line 27 | skipping to change at line 27 | |||

2) The code "ibase=16; obase=10; FF" outputs FF, not 255. Isn't this | 2) The code "ibase=16; obase=10; FF" outputs FF, not 255. Isn't this | |||

a bug? | a bug? | |||

No. ibase changed the input base at that point. The 10 is then in | No. ibase changed the input base at that point. The 10 is then in | |||

base 16 and thus is the value 16. Therefore, both ibase and obase | base 16 and thus is the value 16. Therefore, both ibase and obase | |||

are 16 (decimal). And FF (base 16) on input is printed as FF (base 16) | are 16 (decimal). And FF (base 16) on input is printed as FF (base 16) | |||

on output. So how can one get 255? First, single digit numbers are | on output. So how can one get 255? First, single digit numbers are | |||

not converted using ibase. So A is always 10 (decimal). The following | not converted using ibase. So A is always 10 (decimal). The following | |||

code will always work. "ibase=F+1; obase=A; FF" and that always prints | code will always work. "ibase=F+1; obase=A; FF" and that always prints | |||

255. | 255. | |||

3) Why is the scale variable ignored on multiply? | ||||

That is the way POSIX specifics multiply. Reread the documentation for | ||||

the multiply operation and see that multiply uses the scales of the | ||||

numbers multiplied to determine the scale of the result. | ||||

4) bc's mod command is not working when I run with "bc -l". | ||||

bc's mod (%) command works like integer remainder when scale is 0. | ||||

The -l flag sets scale to 20 and that chanes how a % b is computed. | ||||

Read the man page for exact details. | ||||

End of changes. 1 change blocks. | ||||

0 lines changed or deleted | | 0 lines changed or added |