Solved

"Floating Point Arithmetic" with Perl

Posted on 2009-04-13
6
777 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
Comment Utility
printf "%.4f",-9.9999999999989e-05

0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 500 total points
Comment Utility
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 500 total points
Comment Utility
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 84

Assisted Solution

by:ozo
ozo earned 500 total points
Comment Utility
0
 

Author Comment

by:dyoung520
Comment Utility
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
Comment Utility
thanks!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

A high-level exploration of how our ever-increasing access to information has changed the way we do our jobs.
In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now