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 revision Previous revision
Next revision
Previous revision
floating_point_calculation [2012/01/27 16:34]
k2patel [Using in Script for Comparision]
floating_point_calculation [2020/08/10 02:35] (current)
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 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 (external edit)