In message <[EMAIL PROTECTED]>, Tom Cosgrove writes: > > What is happening here is that when you enter > > ibase=16 > l(0.1) > > you get "0.0" passed to the l() function, which gives -infinity. (I > would call that the expected result under the circumstances.) > > If you enter > > ibase=16 > l(0.10) > > you get "0.06" passed to the l() function, which then gives you the > sort of result you were expecting.
Indeed!!! I missed the point in the post of Otto Moerbeek. You are certainly right, if 0, not 0.1, is passed to the logarithmic function we must expect a minus infinity as returned value. Sorry, it was so obvious... it is my mistake. I am certainly not accustomed to the way numbers are trunked in bc... even if this thread is now focused in the behaviour of bc on decimal rounding I miss the point! > In other words, bc(1) works internally in base 10, and converts numbers > entered in another base into a decimal number with the same precision > before processing those numbers. And, of course, using very coarse > precisions can result in results wildly different to those expected. It seems that Solaris bc is not strictly following the rules. > Maybe this just warrants a CAVEAT in the man page? Indeed... but not a note about the behaviour of l(), just a note about the way non-integer numbers are trunked. It will certainly help people understanding the behaviour of bc and the fact it is not a bug but a consequence of a bad decision in the standard (I would not use these words... but certainly the standard is broken from the point of view of a mathematician) Thanks a lot for the note on the behaviour of l(). You are absolutely right. I am now in front of a PC running Linux at my University: sh-2.05b$ bc -l bc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. ibase=16 l(0.1) -1208925819614629174706175.00000000000000000000 l(0) -1208925819614629174706175.00000000000000000000 0.1 0 On the Solaris workstation (a 64-bit Blade 2000) at the Department of Geological Sciences we have: $ bc -l ibase=16 l(0.1) -2.77258872223978123766 l(0) -99999999999999999999 0.1 .06250000000000000000 0 0 Hey! 0.1 is 0.625!!! Now I see the point on the post of Otto... well... I have some problems understanding how bc works on Solaris yet, but it is a different matter... l(.06250000000000000000) -3.72961498590084712649 In any case, it seems that Solaris' bc is not following the standard. Igor.

