Solved

"Floating Point Arithmetic" with Perl

Posted on 2009-04-13
6
780 Views
Last Modified: 2013-12-25
How can I use Perl for Floating Point Arithmetic in a manner like a calculator does.

For Example:

#!/usr/bin/perl

$number = 0.5299 - 0.5300;

print $number;

...

Prints: -9.9999999999989e-05

I want: -0.0001

Any help is appreciated!!!

Thanks,
Dan
0
Comment
Question by:dyoung520
  • 4
  • 2
6 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 24131521
printf "%.4f",-9.9999999999989e-05

0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 500 total points
ID: 24131562
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 500 total points
ID: 24131623
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 84

Assisted Solution

by:ozo
ozo earned 500 total points
ID: 24131732
0
 

Author Comment

by:dyoung520
ID: 24131808
Thank You...

"printf "%.4f",-9.9999999999989e-05"
I read something to that effect, but I didn't think it as the problem...

Again thank you!
0
 

Author Closing Comment

by:dyoung520
ID: 31569601
thanks!
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Free HD cloner 11 63
Example unit tests with AngularJS 3 45
Suggestions of cloud services for small businesses 9 37
Automatic dictation/transcribing software 9 35
Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question