Just for completeness, I tested it with python and tcl to see if the underlying Tk has a problem. Both worked without problem.

I did test it on perl 5.24.0 with the following code:

#!/usr/bin/perl -w use warnings; use strict; use Tk; use Devel::Peek; my $scale = 22.5; my $x = 14; my $foo = $x * $scale; # use in numeric context (set NV and IV) my $sb = 22.5 * 14; my $i=0; print "\n0 str: <$scale> / num: <".(0+$scale)."> product $foo should b +e $sb\n"; Dump($scale); my $mw = MainWindow->new; $mw->Entry(-textvariable=>\$scale)->pack; $mw->bind("<Key-Return>",\&calc); MainLoop; sub calc { $foo = $scale * $x; my $s2 = $scale.' '; my $foobar = $s2 * $x; $i++; print "\n$i str: <$scale> / num: <".(0+$scale)."> product $foo str +ingified $foobar should be $sb\n"; Dump($scale); }

This seemed to work originally. If you just hit enter a couple of times it fails with:

0 str: <22.5> / num: <22.5> product 315 should be 315 SV = PVNV(0x19572d0) at 0x1982d20 REFCNT = 2 FLAGS = (NOK,pIOK,pNOK) IV = 22 NV = 22.5 PV = 0x196fa80 "22.5"\0 CUR = 4 LEN = 32 1 str: <22.5> / num: <22> product 315 stringified 315 should be 315 SV = PVMG(0x1ed5f60) at 0x1982d20 REFCNT = 3 FLAGS = (GMG,SMG,IOK,NOK,POK,pIOK,pNOK,pPOK,UTF8) IV = 22 NV = 22.5 PV = 0x196fa80 "22.5"\0 [UTF8 "22.5"] CUR = 4 LEN = 32 MAGIC = 0x1fa6a30 MG_VIRTUAL = &PL_vtbl_uvar MG_TYPE = PERL_MAGIC_uvar(U) MG_LEN = 24 MG_PTR = 0x1f24b40 "\260(=\252\254\177\0\0\20==\252\254\177\0\0\0j +\372\1\0\0\0\0" 2 str: <22.5> / num: <22> product 308 stringified 315 should be 315 SV = PVMG(0x1ed5f60) at 0x1982d20 REFCNT = 3 FLAGS = (GMG,SMG,IOK,NOK,POK,pIOK,pNOK,pPOK,UTF8) IV = 22 NV = 22.5 PV = 0x196fa80 "22.5"\0 [UTF8 "22.5"] CUR = 4 LEN = 32 MAGIC = 0x1fa6a30 MG_VIRTUAL = &PL_vtbl_uvar MG_TYPE = PERL_MAGIC_uvar(U) MG_LEN = 24 MG_PTR = 0x1f24b40 "\260(=\252\254\177\0\0\20==\252\254\177\0\0\0j +\372\1\0\0\0\0"

As you can see in section 2, the product reverted to 308 going back to the IV value. The same thing happened on 5.20.1. The flags changed a little, but the results were the same.

I've submitted a report on this to bug-Tk at rt.cpan.org


In reply to Re^3: Perl is ignoring fractional part sometimes by jinnicky
in thread Perl is ignoring fractional part sometimes by jinnicky

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.