- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Mathmatical term in the script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2008 02:52 PM
тАО07-06-2008 02:52 PM
Mathmatical term in the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2008 04:41 PM
тАО07-06-2008 04:41 PM
Re: Mathmatical term in the script
Or use ksh93 (dtksh) or awk. See these two threads:
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1151323
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1171007
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2008 04:57 PM
тАО07-06-2008 04:57 PM
Re: Mathmatical term in the script
Script = ?
What language, or do you care? Shells, in general to integer arithmetic. However, the Korn93 (ksh93) shell supports real values:
# cat showme
#!/usr/dt/bin/dtksh
typeset -F2 R1
typeset -E R2
let R1=1/8+1
echo ${R1}
let R2=1/8+1
echo ${R2}
# ./showme
1.13
1.125
Notice that 'printf' supports rounding and can be used in 'awk or Perl:
# awk 'BEGIN{printf "%3.2f\n", 1/8+1}'
1.12
# awk 'BEGIN{printf "%3.2f\n", 2/3}'
0.67
# perl -e 'BEGIN{printf "%3.2f\n", 2/3}'
0.67
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-24-2008 02:07 AM
тАО07-24-2008 02:07 AM
Re: Mathmatical term in the script
I prefer to use 'bc'. And it is easy to use with negative numbers:
print "scale=0; 24 + 3.23" | bc
print "scale=0; -24 + 3" | bc
print "scale=2; -24 / 7" | bc
var1=-24
var2=7
print "scale=5; $var1 / $var2" | bc
output:
27.23
-21
-3.42
-3.42857
Regards,
Vadim
- Tags:
- bc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-24-2008 02:10 AM
тАО07-24-2008 02:10 AM
Re: Mathmatical term in the script
I prefer to use 'bc'. And it is easy to use with negative numbers:
print "scale=2; 24 + 3.23" | bc
print "scale=0; -24 + 3" | bc
print "scale=2; -24 / 7" | bc
var1=-24
var2=7
print "scale=5; $var1 / $var2" | bc
output:
27.23
-21
-3.42
-3.42857
Regards,
Vadim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-24-2008 02:10 AM
тАО07-24-2008 02:10 AM
Re: Mathmatical term in the script
I prefer to use 'bc'. And it is easy to use with negative numbers:
print "scale=2; 24 + 3.23" | bc
print "scale=2; -24 + 3" | bc
print "scale=2; -24 / 7" | bc
var1=-24
var2=7
print "scale=5; $var1 / $var2" | bc
output:
27.23
-21
-3.42
-3.42857
Regards,
Vadim