I like this answer.
The input is NOT a float, it is a string of decimal digits which could potentially be represented by a binary float.
I would move the decimal 2 places to the right, 12.=>1200, 12.3=>1230 and see if any non-zero digits remain. If so, there are going to be problems when comparing numbers. I would not convert "12.30" to a float unless you have to.

This API is giving the OP a decimal character string instead of a much more compact, efficient binary float. I suspect that there are reasons behind that the OP hasn't told us. This string could have come from some BCD (Binary Coded Decimal) calculation or whatever. I have never written any BCD code, but yes there are math operations that modern processors can do on arrays of BCD's (every 4 bits only goes 0-9 instead of 0-F).


In reply to Re^2: number comparison with a twist by Marshall
in thread number comparison with a twist by anotherguest

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.