?
Solved

"Floating Point Arithmetic" with Perl

Posted on 2009-04-13
6
Medium Priority
?
810 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 85

Accepted Solution

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

0
 
LVL 85

Assisted Solution

by:ozo
ozo earned 2000 total points
ID: 24131562
0
 
LVL 85

Assisted Solution

by:ozo
ozo earned 2000 total points
ID: 24131623
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 85

Assisted Solution

by:ozo
ozo earned 2000 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

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

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

MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Conducting a customer service survey used to be as straightforward as sending a template email out using checkboxes and numerical rating systems to measure satisfaction.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

593 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