The tag has no usage guidance.

learn more… | top users | synonyms

172
votes
16answers
140k views

How to do integer & float calculations, in bash or other languages/frameworks?

Using echo "20+5" literally produces the text "20+5". What command can I use to get the numeric sum, 25 in this case? Also, what's the easiest way to do it just using bash for floating point? For ...
14
votes
3answers
7k views

How is bc different from dc?

What are the differences between dc and bc calculators? When should I use dc and when bc?
10
votes
1answer
10k views

Does bc support hex calculations?

I'm trying to do a hex calculation directly with bc, I already specified the scale. echo 'scale=16;c06b1000-c06a5e78' | bc But I still get a zero. What could be wrong?
7
votes
5answers
6k views

bc doesn't support log and factorial calculation?

Is there any other command line calculator that supports log, n! calculations ? At least bc can't do that, it told me parse error It's best if I could use script, e.g echo '5!' | program
6
votes
2answers
566 views

how to add command line calculator to bash that uses comma as decimal mark?

How can I add a command line calculator to my bash? I have found some, but all of them use the full stop as decimal mark, but I want to have it to use the comma as decimal mark as most of the world ...
5
votes
4answers
21k views

Calculate variable, and output it to another variable

The only calculator I know is bc. I want to add 1 to a variable, and output to another variable. I got the nextnum variable from counting string in a file: nextnum=`grep -o stringtocount file.tpl....
4
votes
1answer
2k views

Installing Linux on the TI-nspire

I am having trouble installing Linux on my TI-nspire cx cas graphing calculator. I downloaded the files and the Linux image. I have read several websites on the topic but it was not that much help, ...
3
votes
1answer
161 views

Perform calculation in hex with Qalculate

I'm trying to do hex calculations, C - A, and I already changed number base to hex, but Qalculate still doesn't work.
3
votes
3answers
3k views

BC—automatic full precision multiplication

High, I need to test my arbitrary precision calculator, and bc seems like a nice yardstick to compare to, however, bc does truncate the result of each multiplication to what seems to be the maximum ...
2
votes
2answers
81 views

dc unix : preserving initial value even after storing new value at the same array index

I'm unable to understand this example given in manpage of dc: $ dc 1 0:a 0Sa 2 0:a La 0;ap 1 To me answer should be 2 because: 1 0:a Here we store 1 at 0th position of array a. 0Sa ...
2
votes
1answer
127 views

calendar to check the date and then search 3 months back and add up the days of those months?

I want to use the cal comand or the date comand to displace the current day then I want it to displace 3 months before the current date then add up all the days in those 3 months up to the current ...
2
votes
1answer
221 views

Make screenshots of Ti-calculator screen

I want to connect a TI-84 Plus Calculator to my PC and take screenshots of the calculator display. Under windows this is possible using the TI-connect software. However is there also a way to do this ...
1
vote
3answers
148 views

bc scale: How to avoid rounding? (Calculate small binomial probability)

Following code calculates the Binomial Probability of a success event k out of n trials: n=144 prob=$(echo "0.0139" | bc) echo -e "Enter no.:" read passedno k=$passedno nCk2() { num=1 den=...
0
votes
2answers
20 views

How to use the result from last calculation in a new calculation in wcalc?

In wcalc how can I do something like -> 1+2 = 3 -> X+1 = 4 where X equals the result of the last calculation (that is 3)?
0
votes
1answer
35 views

Unix command to return maximum float value out of two after subtraction

This is similar to question about getting the minimum/maximum of two numbers, but I'm interested to do the same with float numbers. So basically I'm trying to use shell arithmetic expansion using the ...
0
votes
2answers
61 views

Any way to customize the initialization of variables in the bc calculator?

The bc calculator appears to assign uninitialized variables the value of zero. I would like to alter this behavior so that when bc encounters an uninitialized variable, it instead flags the expression ...
0
votes
1answer
90 views

Where are the variables stored for mate-calc?

I know that there's no way to delete them by default in the application, but they have to be stored somewhere? I'm pretty handy with the command line, so I can do some such there. I believe that ...