Sponsored Content
Full Discussion: Calculator
Top Forums Shell Programming and Scripting Calculator Post 302189327 by in2nix4life on Friday 25th of April 2008 12:31:18 PM
Old 04-25-2008
Since Bash only recognizes normal integers, you can pipe the math through the 'bc' utility and it'll return float values.

RES=$(echo "$IN1" "$OPR" "$IN2" | bc)

Hope this helps.
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

calculator program..

Hey can anyone tell me the korn script code to implement an interactive integer calculator using the shell's built in arithemetic expression evaluation (2 Replies)
Discussion started by: sahithi_khushi
2 Replies

2. UNIX for Dummies Questions & Answers

calculator

hi, im new to the unix system and scripting and was wondering if anyone could help me with this problem iv been havin... i want the system to: 1. ask me for a number 2. ask me for a command to use on that number (* + - /) 3. ask me for another number 4. then ask me for another command, if the... (2 Replies)
Discussion started by: jdougy
2 Replies

3. Shell Programming and Scripting

Help with calculator code

Hi Guys, I found this code in net.. it is working fine.. But can anybody explain me the sed statement used in the code.. echo "Enter the expression:\c" read express eval echo "$express"|sed 's/^/'$precision' \ /'|bc -l|\ sed -n '1,${ /syntax/!{ } ... (2 Replies)
Discussion started by: mac4rfree
2 Replies

4. Shell Programming and Scripting

Permission bit calculator ???

Hi, Does anyone have a UNIX permission bit calculator script that I can use? Basically, am looking for one where I don't have to a ls -l to check the permission on a file or directory. Am looking for a script that will display the permission bits and then just display what those permission... (1 Reply)
Discussion started by: newbie_01
1 Replies

5. Homework & Coursework Questions

Problem with calculator script

I'm having some trouble implementing a basic calculator using command line options. The script is supposed to take (multiple) arguments -a,-d,-m,-s for addition, multiplication, division, and subtraction. I'm pretty sure I know how to parse through the options with getopt(), but I have no idea... (17 Replies)
Discussion started by: zkapopou
17 Replies

6. Shell Programming and Scripting

chmod calculator script

so just spit ballin here, i was wondering if anybody knew how to make a chmod calculator script. basically go to this website http://mistupid.com/internet/chmod.htm i would like something like this that i can use in a terminal tho. so like i run the scrip and it ask for owner what... (1 Reply)
Discussion started by: hookitup
1 Replies

7. Homework & Coursework Questions

Simple Calculator

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known/data: Script a simple calculator. In the command line enter the script file /home/etc/mycalc or /home/etc/mycalc 1 +... (6 Replies)
Discussion started by: herb bertz
6 Replies

8. Homework & Coursework Questions

Creating a calculator with condition

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Create a calculator application in your home folder called itncacl that will perform the following applications:... (5 Replies)
Discussion started by: mugiboya
5 Replies
CONCALC(1)							   User Commands							CONCALC(1)

NAME
concalc - console calculator SYNOPSIS
concalc [options] "expression" concalc -m script "path" DESCRIPTION
concalc calculates the given input term and returns the result as text. Please use will have problems with the shell interpretor. If you give concalc more than one expression, all expression will be put together. CALCULATION SYNTAX
standard calculations 2*(3+4/9)^3 standard operations + - * / ^ % sin cos tan asin acos atan sinh cosh tanh asinh acosh atanh ln log & | ! && || ~ >> << x rnd sqrt curt root integ d/dx sqare root and cubic root sqrt12 curt8 trigonometric functions and logarithms sin3.64+ln5 other roots fourth root of nine: 4root9 differential calculation differential calculation of 2x^2-3x+3 at x=9: d/dx(2x^2-3x+3,9) integration integration of sinx+cosx between -1 and 3.2: integ(sinx+cosx,-1,3.2) set variables save the result of a calculation in variable A: 12*45/2->A recall variables multiply the saved value with 2: A*2 use last result The last result is saved in the answer memory: ans+1 CONSTANTS
e euler constant pi pi; example: sin(pi/2) NUMBERS
standard 12.34 with exponent 12.23e-5 complex 12i-5 OPTIONS
-o, --output [output length] The argument is a number between 2 and the maximal possible output length (normally 18). -m, --mode [calculator mode] The mode can be std (default, normal scientific calculatons), base (for logic functions and base-n calculatons) or script (for exe- cuting scripts). In scripting mode, the last argument must be the path to the script file. -c, --complex This option enables complex numbers for the calculation. They are switched off by default. -b, --base [calculator base] The argument must be one of hex (hexadecimal), dec (decimal, default), oct (octal) and bin (binary). This option can only be used when -m base is set. -a, --angle [angle type] The argument must be one of deg (degrees), rad (radiant), gra (grade). -v, --version Output the version of Concalc. -h, --help Outputs a short help. SCRIPTING
The script interpreter of calc uses a C-like programming syntax. The following command are supported. if expression if(condition) command for condition true; else command for condition false; while loop while(condition) command that is run while condition is true; for loop for(initialisation; condition; count-command) command that is run while condition is true; print command print( output to print out ); getline command getline; // read a text line from stdin and returns this text getkey command getkey; // return the key pressed by the user // blocks until the user presses any key keystate command keystate; // returns the key pressed by the user or 0 if no key was pressed // nonblocking sleep command sleep( time in microseconds ); //Script is stops for the given time compare operators ==, != equal, unequal >=, <=, >, < greather or equal, less or equal, greather, less set operators -> calculator set operator = C-like set operator type converting (float) floating point value (int) integer value (string) text value (bool) boolean value BUGS
No bugs known! If you find one, please report it by e-mail to the author. AUTHOR
Rainer Strobel <rainer1223@users.sourceforge.net> SEE ALSO
http://extcalc-linux.sourceforge.net Linux APRIL 2007 CONCALC(1)
All times are GMT -4. The time now is 06:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy