User Tools

Site Tools


floating_point_calculation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
floating_point_calculation [2012/01/27 16:07] – [Doing Calculation] k2patelfloating_point_calculation [2012/01/27 16:35] – [Using in Script for Comparision] k2patel
Line 15: Line 15:
 Usage is quite simple:  Usage is quite simple: 
  
-<code oobas>+<code bash>
   float_eval '12.0 / 3.0'   float_eval '12.0 / 3.0'
   if float_cond '10.0 > 9.0'; then   if float_cond '10.0 > 9.0'; then
Line 26: Line 26:
 The code for the functions follows:  The code for the functions follows: 
  
-<code oobas>+<code bash>
 #!/bin/bash #!/bin/bash
 # #
Line 103: Line 103:
 The work of the functions is done by feeding the arguments to ''bc'':  The work of the functions is done by feeding the arguments to ''bc'': 
  
-<code oobas>+<code bash>
    result=$(echo "scale=$float_scale; $*" | bc -q 2>/dev/null)    result=$(echo "scale=$float_scale; $*" | bc -q 2>/dev/null)
 </code> </code>
Line 112: Line 112:
 If you save the script as ''float.sh'' and run it directly it will execute the test code at the bottom:  If you save the script as ''float.sh'' and run it directly it will execute the test code at the bottom: 
  
-<code oobas>+<code bash>
   $ sh float.sh   $ sh float.sh
   12.5 / 3.2 is 3.90   12.5 / 3.2 is 3.90
floating_point_calculation.txt · Last modified: 2020/08/10 02:35 by 127.0.0.1