Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

For simple calculations on floating point numbers (+-*/ and comparisons), you can use awk.

min=$(echo 12.45 10.35 | awk '{if ($1 < $2) print $1; else print $2}') 

Or, if you have ksh93 or zsh (not bash), you can use your shell's built-in arithmetic, which supports floating point numbers.

if ((min>val)); then ((val=min)); fi 

For more advanced floating point calculations, look up bc. It actually works on arbitrary-precision fixpoint numbers.

To work on tables of numbers, look up RR (example).

For simple calculations on floating point numbers (+-*/ and comparisons), you can use awk.

min=$(echo 12.45 10.35 | awk '{if ($1 < $2) print $1; else print $2}') 

Or, if you have ksh93 or zsh (not bash), you can use your shell's built-in arithmetic, which supports floating point numbers.

if ((min>val)); then ((val=min)); fi 

For more advanced floating point calculations, look up bc. It actually works on arbitrary-precision fixpoint numbers.

To work on tables of numbers, look up R (example).

For simple calculations on floating point numbers (+-*/ and comparisons), you can use awk.

min=$(echo 12.45 10.35 | awk '{if ($1 < $2) print $1; else print $2}') 

Or, if you have ksh93 or zsh (not bash), you can use your shell's built-in arithmetic, which supports floating point numbers.

if ((min>val)); then ((val=min)); fi 

For more advanced floating point calculations, look up bc. It actually works on arbitrary-precision fixpoint numbers.

To work on tables of numbers, look up R (example).

replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

For simple calculations on floating point numbers (+-*/ and comparisons), you can use awk.

min=$(echo 12.45 10.35 | awk '{if ($1 < $2) print $1; else print $2}') 

Or, if you have ksh93 or zsh (not bash), you can use your shell's built-in arithmetic, which supports floating point numbers.

if ((min>val)); then ((val=min)); fi 

For more advanced floating point calculations, look up bc. It actually works on arbitrary-precision fixpoint numbers.

To work on tables of numbers, look up R (exampleexample).

For simple calculations on floating point numbers (+-*/ and comparisons), you can use awk.

min=$(echo 12.45 10.35 | awk '{if ($1 < $2) print $1; else print $2}') 

Or, if you have ksh93 or zsh (not bash), you can use your shell's built-in arithmetic, which supports floating point numbers.

if ((min>val)); then ((val=min)); fi 

For more advanced floating point calculations, look up bc. It actually works on arbitrary-precision fixpoint numbers.

To work on tables of numbers, look up R (example).

For simple calculations on floating point numbers (+-*/ and comparisons), you can use awk.

min=$(echo 12.45 10.35 | awk '{if ($1 < $2) print $1; else print $2}') 

Or, if you have ksh93 or zsh (not bash), you can use your shell's built-in arithmetic, which supports floating point numbers.

if ((min>val)); then ((val=min)); fi 

For more advanced floating point calculations, look up bc. It actually works on arbitrary-precision fixpoint numbers.

To work on tables of numbers, look up R (example).

Source Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k

For simple calculations on floating point numbers (+-*/ and comparisons), you can use awk.

min=$(echo 12.45 10.35 | awk '{if ($1 < $2) print $1; else print $2}') 

Or, if you have ksh93 or zsh (not bash), you can use your shell's built-in arithmetic, which supports floating point numbers.

if ((min>val)); then ((val=min)); fi 

For more advanced floating point calculations, look up bc. It actually works on arbitrary-precision fixpoint numbers.

To work on tables of numbers, look up R (example).