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:06]
k2patel [Doing Calculation]
floating_point_calculation [2012/01/27 16:35]
k2patel [Using in Script for Comparision]
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
Line 254: Line 254:
 </​code>​ </​code>​
  
-Ref. [[ Novell | http://​www.novell.com/​coolsolutions/​tools/​17043.html]]+Ref. [[ http://​www.novell.com/​coolsolutions/​tools/​17043.html ​| Novell Cool Solutions ​]]
  
  
floating_point_calculation.txt ยท Last modified: 2020/08/10 02:35 (external edit)