Skip to main content

Questions tagged [bc]

Arbitrary-precision arithmetic language.

2 votes
1 answer
264 views

Consider: heightScaled=$(bc <<< $H*$S/1) echo $heightScaled 45.0 Why am I getting 45.0 despite the same operations yielding 45 if used outside the script either interactively or piped into ...
VoQZ's user avatar
  • 29
0 votes
2 answers
113 views

When you do math in bc it clearly uses some order of operations. And I know that this falls within the realm of Reverse Polish Notation; so is it possible for it to explain itself? I mean I know I can ...
leeand00's user avatar
  • 4,971
4 votes
1 answer
303 views

I am using the bc calculator with obase and ibase to convert integer representation. I'm not used to it, because very basic things can be done with $(( expresion )) in bash, and most things that can't ...
Gyro Gearloose's user avatar
-2 votes
1 answer
360 views

I just wrote a small bash shell script and for the first time in that context I wanted to make a calculation, a division, and discovered bc. My script processes media files and I want to log the ...
d-b's user avatar
  • 2,077
-2 votes
2 answers
244 views

Consider the following: $ echo "-1" | bc -1 $ echo "(1)" | bc 1 $ echo "+1" | bc (standard_in) 1: syntax error Minus sign and round braces are handled correctly but ...
Anton Samokat's user avatar
1 vote
1 answer
87 views

I have two old machines, running CentOS 6.5 and CentOS 6.10. Both have bc 1.06.95-1.el6 installed. One reads $HOME/.bc.rc, one does not. Why ? (How??) strace shows near-identical output, except one ...
Andrew Daviel's user avatar
2 votes
1 answer
131 views

I would like to use m4 interactively as a preprocessor for bc. My immediate use case is to add an include capability to bc, but I can foresee other uses in the future. But there is a problem. Here is ...
user448810's user avatar
0 votes
3 answers
190 views

I am trying to multiply array values with values derived from the multiplication of a loop index using bc. #!/bin/bash n=10.0 bw=(1e-3 2.5e-4 1.11e-4 6.25e-5 4.0e-5 2.78e-5 2.04e-5 1.56e-5 1.29e-5 1....
csnl's user avatar
  • 35
3 votes
1 answer
367 views

System: Ubuntu 22.04.3 LTS GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) bc 1.07.1 Observation: Both ibase and obase are unset. echo "A0" | bc 90 echo "B0" | bc 90 ...
yossi-matkal's user avatar
0 votes
0 answers
71 views

is it possible to integrate bc command line calculator in an app (script interpreter) as a library? I am not asking if that can be done, I am asking if there is something ready already that wraps bc ...
Gussak Thor's user avatar
1 vote
1 answer
250 views

I can pipe echo into bc. But I cannot do the same with "printf": it gives syntax error. ❯ echo "100-5" | bc 95 ❯ printf "%s" "100-5" | bc (standard_in) 1: ...
robertspierre's user avatar
1 vote
1 answer
4k views

I have this command that works correct. However it shows a (standard_in) 1: Syntax error that I don't know how to identify. participants=0 while IFS=, read -r id name nat sex date height weight sport ...
CPG's user avatar
  • 25
1 vote
2 answers
218 views

I've found that there is an upper-bound on your subscripts/indices in an array in GNU bc. Running interactively and asking to let arr[100000000]=42 returns an error: Runtime error (func=(main), adr=...
Mike Pierce's user avatar
10 votes
3 answers
5k views

I'm using bc in Ubuntu Linux. It has a pre-defined constant PI that's set to 99. Why does bc define PI to be 99 instead of 3.14159...?
Jim's user avatar
  • 101
2 votes
0 answers
111 views

bash --version GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin21.1.0) I'm calling a script (dewpoint) which contains a bc calculation that defines dewpoint based on temp(c) and humidity(%). ...
rr0ss0rr's user avatar
  • 366

15 30 50 per page
1
2 3 4 5
9