- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Arithmetic operation on decimals
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
Forums
Discussions
Discussions
Discussions
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
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
10-21-2007 09:25 AM
10-21-2007 09:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2007 09:45 AM
10-21-2007 09:45 AM
Re: Arithmetic operation on decimals
Or use fixed point scaled arithmetic.
I'm not sure if dtksh supports it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2007 09:51 AM
10-21-2007 09:51 AM
Re: Arithmetic operation on decimals
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1151323
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2007 09:57 AM
10-21-2007 09:57 AM
Re: Arithmetic operation on decimals
HP-UX offers a Korn93 shell which supports floating point arithmetic:
# cat ./domath
#!/usr/dt/bin/dtksh
typeset -F R1
typeset -F3 R2
typeset -E R3
typeset -F1 R4
let R1=1/8
echo ${R1}
let R2=1/8
echo ${R2}
let R3=1/8
echo ${R3}
let R4=142.5+586.1
echo ${R4}
# ./domath
.1250000000
.125
0.125
728.6
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2007 10:47 AM
10-21-2007 10:47 AM
Solution>> How to do arithmetic operations on decimal.
like adding 142.5 and 586.1?
Then, might I suggest one of those $1.50 calculators you can get at the local supermarkets?
ok, I'm teasing you here, but you see what I mean?
What is the real problem you are trying to solve?
Where are the numbers coming from, where are they going to be consumed?
The shell solution MIGHT be a quick awk program, or 'bc' or 'dc'
For example:
$ TEST=$(echo 142.5 + 586.1 | bc -l)
$ echo $TEST
728.6
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2007 07:08 PM
10-23-2007 07:08 PM