How to get a decimal number when dividing in bc?

scale = 20 It sets the number of decimal places. $ bc 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’. 355/113 3 scale=20 355/113 3.14159292035398230088 quit $

bc is ignoring scale option

as Carl pointed out, if you check man page, you can find that line. it is about expression explanations. subtraction won’t read scale variable. If you want to get the expected result (1.30), you could: kent$ echo ‘scale=2; (2.777 – 1.4744)/1’ | bc 1.30 / operation will read scale variable.

How to get bc to handle numbers in scientific (aka exponential) notation?

Unfortunately, bc doesn’t support scientific notation. However, it can be translated into a format that bc can handle, using extended regex as per POSIX in sed: sed -E ‘s/([+-]?[0-9.]+)[eE]\+?(-?)([0-9]+)/(\1*10^\2\3)/g’ <<<“$value” you can replace the “e” (or “e+”, if the exponent is positive) with “*10^”, which bc will promptly understand. This works even if the exponent … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)