Try replacing the data output line with:
warn sprintf "scale: %.40f\nscaled_index: %.40f\n" . "index: %.40f\nadjusted_hue: %.40f\n\n", $scale, $scaled_index, $index, $adjusted_hue;
then you'll see the following two outputs for the supposedly identical 0.3 cases:
adjusted_hue (75) equals 75 scale: 0.2999999999999999888977697537484345957637 scaled_index: 3.0000000000000000000000000000000000000000 index: 3.0000000000000000000000000000000000000000 adjusted_hue: 75.0000000000000000000000000000000000000000 adjusted_hue (75) does not equal 75 scale: 0.3000000000000000444089209850062616169453 scaled_index: 3.0000000000000004440892098500626161694527 index: 3.0000000000000000000000000000000000000000 adjusted_hue: 75.0000000000000142108547152020037174224854

Dave.


In reply to Re: Why is this comparison failing? by dave_the_m
in thread Why is this comparison failing? by johnrcomeau

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.