- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script that can handle exponentials
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
03-28-2005 03:19 AM
03-28-2005 03:19 AM
basically i am writing a very simple calculator for some engineers here but have no idea on how to add, subtract, multiply, etc.. values in the format 8.03e-3
in the past i have used "bc" but not sure if there was an elegant way of working with exponents like this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2005 03:24 AM
03-28-2005 03:24 AM
Re: script that can handle exponentials
I don't do perl, but suspect that it too uses bc.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2005 03:34 AM
03-28-2005 03:34 AM
Solution#!/usr/bin/perl
my $a = 7.00e-5;
my $b = 2000.0
my $c = $a * $b;
printf("Fixed point: %10.2f Exponential: %e\n",$c,$c);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2005 06:34 AM
03-28-2005 06:34 AM
Re: script that can handle exponentials
then you do something like this:
----
#!/usr/bin/ksh
a="7.00*e(-5)"
b="5.00*e(2)"
echo "a=($a)*($b)" | bc -l
----
Basically, you need to take the user input and
format it to a string like 'a' and 'b' as shown
above. See bc(1) manpages for all the cool maths
things you can do.
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2005 06:37 AM
03-28-2005 06:37 AM
Re: script that can handle exponentials
script to:
---
#!/usr/bin/ksh
a="7.00*e(-5)"
b="5.00*e(2)"
echo "($a)*($b)" | bc -l
---
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2005 08:11 AM
03-28-2005 08:11 AM