Skip to main content

Questions tagged [bc]

"Basic Calculator," an arbitrary-precision calculator language. General bc questions are a better fit for unix.stackexchange.com, while "programming" questions about bc fit on stackoverflow.com.

-3 votes
1 answer
92 views

I am trying to convert non-base 10 (non-decimal) numbers to each other by using bc command in Linux, but the answers are different from what I expected. ibase = 3 obase = 7 23 11 Why is the answer 11?...
Sorenyt Mikelyt's user avatar
0 votes
2 answers
3k views

The original problem This may be more of a bc or bash question than an FFmpeg one, although I would also appreciate being able to prevent ffprobe from printing carriage returns after its output. In a ...
Hashim Aziz's user avatar
  • 14.2k
0 votes
2 answers
2k views

In PowerShell, how do I evaluate a mathematical expression stored as a string? How do I get PowerShell to evaluate the following: C:\> $a="30000/1001" C:\> $a 30000/1000 C:\> Desired output:...
Brian's user avatar
  • 1,125
1 vote
2 answers
830 views

I'm trying to use Bash to complete Project Euler 13. Below is my code that I just cannot figure out what's wrong with. #!/bin/bash sum=0 ...
Egrodo's user avatar
  • 169
2 votes
1 answer
481 views

I'm looking to repeat this code until I stop it, either by setting a time for which it repeats, pressing ^c, or set number of iterations, and then output the result of repeating it. The code should ...
Hellreaver's user avatar
0 votes
1 answer
86 views

I have written shell script to substract two float values For eg. below are the two values : debit_amount=7.853117806000353E7 credit_amount=3223649.619999993 val1=$(printf "%f", "$debit_amount") ...
user's user avatar
  • 209
0 votes
1 answer
189 views

Unfortunately this result in a empty variable, and bc command print its result to terminal anyway while trying to attribute to aux aux=&(bc -l <<< "scale = 5; c(${arguments[0]}*$constant)...
RomuloPBenedetti's user avatar
1 vote
2 answers
419 views

I’ve encountered an error, probably a bug in bc. I encountered it when trying to compare two numbers on a script in bash. It turns out that when I do: echo "1.1E-2<1.1E-1" | bc -l It returns 1 (as ...
juan monti's user avatar
2 votes
3 answers
1k views

GNU bc is very unconventional. I can't find anything online about how to get it to print a newline character. I'm trying to get it to print the first 16 hexadecimal digits of the sines of the integers ...
Melab's user avatar
  • 1,309
5 votes
1 answer
352 views

>>> 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'. ibase = 16 obase = 56 ...
Alan H.'s user avatar
  • 2,968
20 votes
3 answers
22k views

bc 1/2 0 5/3 1 10/3 3 When a fraction is entered into bc, the result is truncated to an integer. How can this behavior be avoided, such that the output of a division operation is a real number?
user001's user avatar
  • 4,044
0 votes
1 answer
894 views

I use bash calculator for floating point calculations and I have to use input redirection and backtick (`) symbol in scripts. As normal bracket $[math operation] and expr doesn't support float ...
P K's user avatar
  • 2,263
1 vote
1 answer
156 views

$ echo 2*1024|bc 20480 $ echo 2.0*1024|bc 2048.0 $ echo 2*1024.0|bc 2048.0 What's going on here then? Update: dc manages fine $ echo "2 1024 * p"|dc 2048
Stephen Paulger's user avatar
5 votes
4 answers
3k views

I'm just starting with Gnu's bc and I'm stuck at the very beginning (very discouraging...). I want to divide two numbers and get a float as result: $bc bc 1.06.94 Copyright 1991-1994, 1997, 1998, ...
Boldewyn's user avatar
  • 4,476
16 votes
5 answers
23k views

If the scale is other than zero, calculations with %, such as 3%2 and 46%4, tend to output 0. How is the algorithm designed with the scale other than 0? bc scale=10 print 4%3 // output 0
user avatar