Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

float

Status
Not open for further replies.

tomte

Technical User
Joined
Nov 14, 2002
Messages
47
Location
US
How do I in a csh, read in a decimal value, ex .05678 from a file and using the expr command apply arithmatic values to a variable. Example: set number = `expr $integer1 \* $decimal2` where decimal2 is the decimal value from a file. I return a null value to to number if decimal2 is a float value, but it works if decimal2 is an integer.
 
Tom:

I'm not a real csh expert, but like ksh88, I don't think csh supports float arithmetic. You can use the bc command:

#!/bin/csh

set y=`echo '5 * 0.25'|bc`
echo $y

The ksh93 version of Korn supports float arithetic.

Regards,


Ed
 
You can also use awk:
printf "%f\n", 20.187 * 34.23345

 
on solaris, /bin/printf will do the same as marsd said.
i prefer oldeds way, no limits
/bin/echo "scale=99;(2^32)/7" | /bin/bc
is a nice one :)
 
Thanks all for the response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top