[ale] Shell script

Justin Russell justin.w.russell at lmco.com
Wed Sep 27 19:45:44 EDT 2000


I've run into this same problem before (the older versions of ksh won't
handle floats), so I just wrote a small C program that takes two
arguments:

#include <stdio.h>

main(int argc, char *argv[])
{
  double num1,num2;

  if (argv[1] != NULL)
  {
    sscanf(argv[1], "%lf",&num1);
    sscanf(argv[2], "%lf",&num2);
    printf("%.12lf",num1+num2);
  }
}


I called it "add".  So, when I want to ass two floats in a script, I
just say 'add float1 float2' which can be placed in a new script
variable if you are doing a sum.  The same thing can be done for other
operations (multiply, divide, etc.)


Hope this helps.




--
-----------------------------------------------
 Justin W. Russell
 Engineer Senior, Aerodynamics/CFD
 Lockheed Martin Aeronautics Company
 86 South Cobb Drive
 Marietta, GA  30063-0685

 Tel:  (770) 494-6303
 Fax:  (770) 494-3055
-----------------------------------------------



--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list