- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- BASIC CALCULATION THRU Korn Shell
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
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
07-04-2003 03:32 AM
07-04-2003 03:32 AM
Need your help to perform simple calculation thru korn shell.
e.g #1
A=3
let B=$A*2
6
Rem = I got it and correct
e.g #2
A=3
let B=$A*1.33
3
Rem = The answer is 3 not 3.99,
Please assist me on how could I get 3.99
TQVM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2003 03:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2003 03:43 AM
07-04-2003 03:43 AM
Re: BASIC CALCULATION THRU Korn Shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2003 04:16 AM
07-04-2003 04:16 AM
Re: BASIC CALCULATION THRU Korn Shell
a=1.33
b=2
ans=$(echo $a $b | awk '{printf"%4.2f\n",$1*$2}')
echo $ans
You can format your output with the printf statement, alternatively just use {print $1*$2} & see waht format you get!
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2003 04:32 AM
07-04-2003 04:32 AM
Re: BASIC CALCULATION THRU Korn Shell
You can try awk. awk is capable of handling the calculation you mentioned.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2003 04:51 AM
07-04-2003 04:51 AM
Re: BASIC CALCULATION THRU Korn Shell
echo "1*2.33"|bc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2003 05:47 AM
07-04-2003 05:47 AM
Re: BASIC CALCULATION THRU Korn Shell
Have a nice day...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2003 06:58 AM
07-04-2003 06:58 AM
Re: BASIC CALCULATION THRU Korn Shell
Sorry for this late answere. It is perhaps forgotten that it is possible to do simple "floating point" calculations with integer arithmetic. It was nessecary with old system which have no floating point support at all. Try the following (3* 1.33):
echo $((3*133/100)).$((3*133%100))
% is the "mod" operator, the rest in a integer division.