- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: scripting question
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
05-14-2001 11:11 AM
05-14-2001 11:11 AM
Anyway to add two decimal numbers of differing precision in a ksh script?
tx,
C
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2001 11:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2001 10:18 AM
05-15-2001 10:18 AM
Re: scripting question
set typ -i x
x=`echo 100.99 + 200.88 | bc`
echo $x
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2001 10:19 AM
05-15-2001 10:19 AM
Re: scripting question
set type -i x
x=`echo 100.99 + 200.88 | bc`
echo $x
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2001 04:40 AM
05-16-2001 04:40 AM
Re: scripting question
set type -i x
is nonsense! This sets $1 to "type", $2 to "-i" and $3 to "x"
But a typeset -i x
would set $x to integer, and this is not usefull here, because the
result is a float.
So simply use:
$ x=$(echo "1.11+3.3"|bc); echo "$x"
4.41
is ok
By the way, mind the precision in bc:
$ echo 'scale=6; 10/3' | bc
3.333333
$ echo 'scale=3; 10/3' | bc
3.333
$ echo '10/3' | bc
3
Hanno
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2001 11:36 AM
05-17-2001 11:36 AM
Re: scripting question
I MADE THE TEST AND ITS FUNCTIONED.
I WOULD LIKE THAT YOU MADE TOO.
THEREFORE WHEN YOU USE BC COMMAND THE
INTEGER VARIABLE BECOMES FLOATING,
OK.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2001 01:03 AM
05-18-2001 01:03 AM
Re: scripting question
I didn't understand your last question but I tested this:
c13:/tmp$ x=$(echo "1.11+3.3"|bc); echo "$x"
4.41
c13:/tmp$ typeset -i x
c13:/tmp$ x=$(echo "1.11+3.3"|bc); echo "$x"
4
So x remains an int if it is set so,
and the result becomes truncated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2001 05:22 AM
05-18-2001 05:22 AM
Re: scripting question
The problem among my test and your test is
the ` `. Your test use () and $ therefore the
results are different.
Test makes equal mine is above and looks at the result. OK !
Regards...
Abel Berger