LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to add decimal numbers in Linux (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-add-decimal-numbers-in-linux-825349/)

MinuPriya 08-10-2010 10:23 AM

How to add decimal numbers in Linux
 
Can anyone specify the methods how to add decimal numbers in Linux

GrapefruiTgirl 08-10-2010 10:27 AM

In what context? You mean from the shell? If so, `bc` would be my first choice, although `awk` can also to arithmetic.

theNbomr 08-10-2010 10:52 AM

Bash, and I assume any Korn oriented shell, cannot do floating point arithmetic. Almost any other programming environment can.
--- rod.

makyo 08-10-2010 09:29 PM

Hi.

Many shells can do integer arithmetic.

Versions of ksh of at least ksh 93s+ can do floating point arithmetic, see man ksh.

Also zsh, see post # 11, http://www.linuxquestions.org/questi...script-336772/

Best wishes ... cheers, makyo

ghostdog74 08-10-2010 09:59 PM

to do calculation, use bc,dc , awk.

b0uncer 08-11-2010 12:31 AM

Or fire up Python, which has those capabilities (and much more, start by importing things from math):
Code:

python
I find it simpler than running an awk command every time I need to calculate something (less typing).

Edit: or if you're fine with typing, you could just
Code:

python -c 'print .2+.8'


All times are GMT -5. The time now is 07:35 AM.