develooper Front page | perl.perl6.internals | Postings from July 2002

[perl #823] [PATCH] put numeric comparisons in the right order

From:
Sean O'Rourke
Date:
July 15, 2002 21:23
Subject:
[perl #823] [PATCH] put numeric comparisons in the right order
Message ID:
rt-823-3869.4.9140913503193@perl
# New Ticket Created by  "Sean O'Rourke" 
# Please include the string:  [perl #823]
# in the subject line of all future correspondence about this issue. 
# <URL: http://bugs6.perl.org/rt2/Ticket/Display.html?id=823 >


NOTE: this may be part of the monster-patch to fix the over-agressive
string GC (814), but it's much more palatable in this form.  PerlInt's
cmp() method was backwards, and would truncate floats on the other side of
the comparison.  This patch always uses floating-point, and makes the
direction consistent with the PDD 2.

/s

Index: perlint.pmc
===================================================================
RCS file: /cvs/public/parrot/classes/perlint.pmc,v
retrieving revision 1.24
diff -u -r1.24 perlint.pmc
--- perlint.pmc 12 Jun 2002 22:12:18 -0000      1.24
+++ perlint.pmc 16 Jul 2002 04:14:09 -0000

@@ -557,14 +558,14 @@
     }

     INTVAL cmp(PMC* value) {
-        INTVAL diff;
-        diff = value->vtable->get_integer(INTERP, value) - SELF->cache.int_val;
+        FLOATVAL diff;
+        diff = SELF->cache.int_val - value->vtable->get_number(INTERP, value);
         return diff > 0 ? 1 : diff < 0 ? -1 : 0;
     }

     INTVAL cmp_num(PMC* value) {
-        INTVAL diff;
-        diff = value->vtable->get_integer(INTERP, value) - SELF->cache.int_val;
+        FLOATVAL diff;
+        diff = SELF->cache.int_val - value->vtable->get_number(INTERP, value);
         return diff > 0 ? 1 : diff < 0 ? -1 : 0;
     }








nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About