Syntactic Confectionery Delight | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Check this page out, It has tests to find variables types, and how to convert them. You can test if a value is an int, if it is convert it to a real and then do the comparison.
http://search.cpan.org/~dwheeler/Data-Types-0.06/lib/Data/Types.pm. With this you should be able to get it to at least the same variable type. If both become float types and and you compare 10.0 to 10.00, you should end up with equality... Another though that you can do is set up a tolerance for precision on number comparisons;
Instead of if a == b do if (absolute value of (a - b)) > .0001 then ..... Just some thoughts. I personally haven't done a lot with Perl yet. In reply to Re^3: Equality checking for strings AND numbers
by Anonymous Monk
|
|