Skip Menu |
Report information
Id: 68898
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: Solomon <colomon [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Patch
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [PATCH] Swap meanings of Int / Int and div
Date: Mon, 31 Aug 2009 19:10:27 -0400
To: rakudobug [...] perl.org
From: Solomon Foster <colomon [...] gmail.com>
Download (untitled) / with headers
text/plain 431b
There are two -- well, three issues with this patch that I know of: 1. div merely has the code for the old Int / Int, but S03 suggests the edge cases should be a bit different. 2. Something is broken in temporal.t, presumably indicating something is broken in Temporal.pm. 3. Rat.perl is probably a bit silly, considering that "N/M" should work. -- Solomon Foster: colomon@gmail.com HarmonyWare, Inc: http://www.harmonyware.com

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Download (untitled) / with headers
text/plain 736b
On Mon Aug 31 16:11:04 2009, colomon@gmail.com wrote: Show quoted text
> There are two -- well, three issues with this patch that I know of: > > 1. div merely has the code for the old Int / Int, but S03 suggests the > edge cases should be a bit different.
I've attached two patches (Rakudo + spectest) that change infix:<div> to use integer semantics. It breaks some edge cases with large integers, but I decided not to care about those for now. Show quoted text
> 2. Something is broken in temporal.t, presumably indicating something > is broken in Temporal.pm.
Still the same with my patch. Show quoted text
> 3. Rat.perl is probably a bit silly, considering that "N/M" should work.
Well, we can change that later on again, but I don't think it's high priority. Cheers, Moritz
Index: t/spec/S02-builtin_data_types/num.t =================================================================== --- t/spec/S02-builtin_data_types/num.t (revision 28143) +++ t/spec/S02-builtin_data_types/num.t (working copy) @@ -19,7 +19,7 @@ #L<S02/Built-In Data Types/Rat supports arbitrary precision rational arithmetic> { - my $a = 1 div 1; + my $a = 1 / 1; isa_ok($a, Rat); is($a, "1/1", '1.0 stringification works'); } @@ -91,7 +91,7 @@ } #L<S02/Built-In Data Types/Rat supports arbitrary precision rational arithmetic> -isa_ok(1 div 1, Rat); +isa_ok(1 / 1, Rat); { my $a = 80000.0000000000000000000000000; Index: t/spec/S02-builtin_data_types/declare.t =================================================================== --- t/spec/S02-builtin_data_types/declare.t (revision 28143) +++ t/spec/S02-builtin_data_types/declare.t (working copy) @@ -29,7 +29,7 @@ } { - my Rat $namcu = 7 div 4; + my Rat $namcu = 7 / 4; isa_ok($namcu,Rat); } @@ -148,7 +148,7 @@ #?rakudo skip 'rat not implemented' { - my rat $namcu = 7 div 4; + my rat $namcu = 7 / 4; isa_ok($namcu,rat); } Index: t/spec/S02-builtin_data_types/type.t =================================================================== --- t/spec/S02-builtin_data_types/type.t (revision 28143) +++ t/spec/S02-builtin_data_types/type.t (working copy) @@ -118,8 +118,8 @@ { # the following two are the same type of behavior # S02: "It is possible for the of type to disagree with the as type" - my Rat sub returntype4 ($pass) as Num {$pass ?? 11 div 10 !! 1} - my sub returntype5 ($pass --> Rat) as Num {$pass ?? 11 div 5 !! 2} + my Rat sub returntype4 ($pass) as Num {$pass ?? 11 / 10 !! 1} + my sub returntype5 ($pass --> Rat) as Num {$pass ?? 11 / 5 !! 2} is(returntype4(True), 1.1, 'good return value works (my Type sub as OtherType)'); eval_dies_ok('returntype4(False)', 'bad return value dies (my Type sub as OtherType)'); Index: t/spec/S32-temporal/Temporal.t =================================================================== --- t/spec/S32-temporal/Temporal.t (revision 28143) +++ t/spec/S32-temporal/Temporal.t (working copy) @@ -31,7 +31,7 @@ '2000-01-01 00:00:00 was on a Saturday in January'; # test 6 $t = time; -$d = (int($t/86400) + 4) % 7 + 1; +$d = (int($t / 86400) + 4) % 7 + 1; $g1 = Time.gmtime($t); $g2 = Time.gmtime; # $g1 and $g2 might differ very occasionally ok $g1.date.year ==$g2.date.year && $g1.date.month ==$g2.date.month && @@ -85,9 +85,9 @@ # An independent calculation to cross check the Temporal algorithms. sub test_gmtime( Num $t is copy ) { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst); - $sec = int($t) % 60; $t = int($t/60); # $t is now epoch minutes - $min = $t % 60; $t = int($t/60); # $t is now epoch hours - $hour = $t % 24; $t = int($t/24); # $t is now epoch days + $sec = int($t) % 60; $t = int($t / 60); # $t is now epoch minutes + $min = $t % 60; $t = int($t div 60); # $t is now epoch hours + $hour = $t % 24; $t = int($t div 24); # $t is now epoch days # Not a sophisticated or fast algorithm, just an understandable one # only valid from 1970-01-01 until 2100-02-28 $wday = ($t+4) % 7; # 1970-01-01 was a Thursday Index: t/spec/S03-operators/assign.t =================================================================== --- t/spec/S03-operators/assign.t (revision 28143) +++ t/spec/S03-operators/assign.t (working copy) @@ -297,10 +297,10 @@ { my $x = 6; - @p = $x /= 3, 4; - is($x, 2, '/= operator'); - is(@p[0],2, "/= operator parses as item assignment 1"); - is(@p[1],4, "/= operator parses as item assignment 2"); + @p = $x div= 3, 4; + is($x, 2, 'div= operator'); + is(@p[0],2, "div= operator parses as item assignment 1"); + is(@p[1],4, "div= operator parses as item assignment 2"); } { Index: t/spec/S03-operators/ternary.t =================================================================== --- t/spec/S03-operators/ternary.t (revision 28143) +++ t/spec/S03-operators/ternary.t (working copy) @@ -21,7 +21,7 @@ } is(($str2 eq $str1 ?? 8 * 8 !! 9 * 9), 64, "?? !! in parenthesis"); -is(($str2 eq $str3 ?? 8 + 8 !! 9 / 9), 1, "?? !! in parenthesis"); +is(($str2 eq $str3 ?? 8 + 8 !! 9 div 9), 1, "?? !! in parenthesis"); is(1 ?? 2 ?? 3 !! 4 !! 5 ?? 6 !! 7, 3, "nested ?? !!"); is(1 ?? 0 ?? 3 !! 4 !! 5 ?? 6 !! 7, 4, "nested ?? !!"); Index: t/spec/S03-operators/hyper.t =================================================================== --- t/spec/S03-operators/hyper.t (revision 28143) +++ t/spec/S03-operators/hyper.t (working copy) @@ -35,7 +35,7 @@ @e = ((1,1,1), (2,2), (3)); is(~@r, ~@e, "hyper-xx two arrays"); - @r = (20, 40, 60) »/« (2, 5, 10); + @r = (20, 40, 60) »div« (2, 5, 10); @e = (10, 8, 6); is(~@r, ~@e, "hyper-divide two arrays"); @@ -65,7 +65,7 @@ @e = ((1,1,1), (2,2), (3)); is(~@r, ~@e, "hyper-xx two arrays ASCII notation"); - @r = (20, 40, 60) >>/<< (2, 5, 10); + @r = (20, 40, 60) >>div<< (2, 5, 10); @e = (10, 8, 6); is(~@r, ~@e, "hyper-divide two arrays ASCII notation"); Index: t/spec/S03-operators/basic-types.t =================================================================== --- t/spec/S03-operators/basic-types.t (revision 28143) +++ t/spec/S03-operators/basic-types.t (working copy) @@ -64,7 +64,7 @@ my $float = 0.5; isa_ok($float, Num, 'it is an Num type'); -isa_ok(1 div 4, Rat, 'infix:<div> produces a Rat'); +isa_ok(1 / 4, Rat, 'infix:</> of integers produces a Rat'); my $string = "Hello World"; isa_ok($string, Str, 'it is a Str type'); Index: t/spec/S03-operators/arith.t =================================================================== --- t/spec/S03-operators/arith.t (revision 28143) +++ t/spec/S03-operators/arith.t (working copy) @@ -263,15 +263,15 @@ # divide -tryeq 28/14, 2; -tryeq 28/-7, -4; -tryeq -28/4, -7; -tryeq -28/-2, 14; +tryeq 28 div 14, 2; +tryeq 28 div -7, -4; +tryeq -28 div 4, -7; +tryeq -28 div -2, 14; -tryeq 0x80000000/1, 0x80000000; -tryeq 0x80000000/-1, -0x80000000; -tryeq -0x80000000/1, -0x80000000; -tryeq -0x80000000/-1, 0x80000000; +tryeq 0x80000000 div 1, 0x80000000; +tryeq 0x80000000 div -1, -0x80000000; +tryeq -0x80000000 div 1, -0x80000000; +tryeq -0x80000000 div -1, 0x80000000; # The example for sloppy divide, rigged to avoid the peephole optimiser. is_approx "20." / "5.", 4; @@ -283,12 +283,12 @@ # Bluuurg if your floating point can't accurately cope with powers of 2 # [I suspect this is parsing string-to-float problems, not actual arith] -is 18446744073709551616/1, 18446744073709551616; # Bluuurg +is 18446744073709551616 div 1, 18446744073709551616; # Bluuurg { - tryeq_sloppy 18446744073709551616/2, 9223372036854775808; - tryeq_sloppy 18446744073709551616/4294967296, 4294967296; - tryeq_sloppy 18446744073709551616/9223372036854775808, 2; + tryeq_sloppy 18446744073709551616 div 2, 9223372036854775808; + tryeq_sloppy 18446744073709551616 div 4294967296, 4294967296; + tryeq_sloppy 18446744073709551616 div 9223372036854775808, 2; } { @@ -323,7 +323,7 @@ { is_approx(-1, (0 + 1i)**2, "i^2 == -1"); is_approx(-1, (0.7071067811865476 + -0.7071067811865475i)**4, "sqrt(-i)**4 ==-1" ); - is_approx(1i, (-1+0i)**(1/2), '(-1+0i)**(1/2) == i '); + is_approx(1i, (-1+0i)**(1 div 2), '(-1+0i)**(1/2) == i '); } { @@ -335,16 +335,16 @@ is Inf+100, Inf; is Inf-100, Inf; is Inf*100, Inf; - is Inf/100, Inf; + is Inf / 100, Inf; is Inf*-100, -Inf; - is Inf/-100, -Inf; - is 100/Inf, 0; + is Inf / -100, -Inf; + is 100 / Inf, 0; is Inf**100, Inf; is Inf*0, NaN; is Inf - Inf, NaN; is Inf*Inf, Inf; - is Inf/Inf, NaN; - is Inf*Inf/Inf, NaN; + is Inf / Inf, NaN; + is Inf*Inf / Inf, NaN; is Inf**0, 1; is 0**0, 1; is 0**Inf, 0; @@ -373,18 +373,18 @@ is NaN+100, NaN; is NaN-100, NaN; is NaN*100, NaN; - is NaN/100, NaN; + is NaN / 100, NaN; is NaN**100, NaN; is NaN+NaN, NaN; is NaN - NaN, NaN; is NaN*NaN, NaN; - is NaN/NaN, NaN; + is NaN / NaN, NaN; is NaN+Inf, NaN; is NaN - Inf, NaN; is NaN*Inf, NaN; - is NaN/Inf, NaN; - is Inf/NaN, NaN; + is NaN / Inf, NaN; + is Inf / NaN, NaN; my $nan1 = NaN**NaN; is $nan1, NaN, "NaN**NaN"; @@ -413,9 +413,9 @@ dies_ok( { $x = 0; say 3 % $x; }, 'Modulo zero dies and is catchable with VInt/VRat variables'); dies_ok( { $x := 0; say 3 % $x; }, 'Modulo zero dies and is catchable with VRef variables'); -dies_ok( { say 3 / 0 }, 'Division by zero dies and is catchable'); -dies_ok( { $x = 0; say 3 / $x; }, 'Division by zero dies and is catchable with VInt/VRat variables'); -dies_ok( { $x := 0; say 3 / $x; }, 'Division by zero dies and is catchable with VRef variables'); +dies_ok( { say 3 div 0 }, 'Division by zero dies and is catchable'); +dies_ok( { $x = 0; say 3 div $x; }, 'Division by zero dies and is catchable with VInt div VRat variables'); +dies_ok( { $x := 0; say 3 div $x; }, 'Division by zero dies and is catchable with VRef variables'); # This is a rakudo regression wrt bignum: #?rakudo skip 'bigint' Index: t/spec/integration/99problems-31-to-40.t =================================================================== --- t/spec/integration/99problems-31-to-40.t (revision 28143) +++ t/spec/integration/99problems-31-to-40.t (working copy) @@ -147,7 +147,7 @@ while $n > 1 { if $n % $cond == 0 { $count++; - $n /= $cond; + $n div= $cond; } else { if $count > 0 { Index: t/spec/integration/99problems-51-to-60.t =================================================================== --- t/spec/integration/99problems-51-to-60.t (revision 28143) +++ t/spec/integration/99problems-51-to-60.t (working copy) @@ -56,14 +56,14 @@ return undef if $n == 0; gather { if $n % 2 == 1 { - my $k = ($n - 1) / 2; + my $k = ($n - 1) div 2; for cbal-tree($k) -> $a { for cbal-tree($k) -> $b { take ['x', $a, $b]; } } } else { - my $k = $n / 2; + my $k = $n div 2; for cbal-tree($k) -> $a { for cbal-tree($k - 1) -> $b { take ['x', $a, $b]; Index: t/spec/S32-num/rat.t =================================================================== --- t/spec/S32-num/rat.t (revision 28143) +++ t/spec/S32-num/rat.t (working copy) @@ -18,12 +18,14 @@ is(~(Rat.new(0,33)), "0/1", "Reduce to simplest form in constructor"); # Test basic math -is(~(1 div 4 + 1 div 4), "1/2", "1/4 + 1/4 = 1/2"); -is(~(1 div 4 + 2 div 7), "15/28", "1/4 + 2/7 = 15/28"); -is(~(1 div 4 + 1), "5/4", "1/4 + 1 = 5/4"); -is(~(1 + 1 div 4), "5/4", "1 + 1/4 = 5/4"); -is(~(1 div 4 - 1 div 4), "0/1", "1/4 - 1/4 = 0/1"); -is(~(1 div 4 - 3 div 4), "-1/2", "1/4 - 3/4 = -1/2"); +is(~(1 / 4 + 1 / 4), "1/2", "1/4 + 1/4 = 1/2"); +is(~(1 / 4 + 2 / 7), "15/28", "1/4 + 2/7 = 15/28"); +is(~(1 / 4 + 1), "5/4", "1/4 + 1 = 5/4"); +is(~(1 + 1 / 4), "5/4", "1 + 1/4 = 5/4"); +is(~(1 / 4 - 1 / 4), "0/1", "1/4 - 1/4 = 0/1"); +is(~(1 / 4 - 3 / 4), "-1/2", "1/4 - 3/4 = -1/2"); +is(~(1 / 4 - 1), "-3/4", "1/4 - 1 = -3/4"); +is(~(1 - 1 / 4), "3/4", "1 - 1/4 = 3/4"); done_testing; Index: t/spec/S02-literals/radix.t =================================================================== --- t/spec/S02-literals/radix.t (revision 28143) +++ t/spec/S02-literals/radix.t (working copy) @@ -106,7 +106,7 @@ # L<S02/Literals/"Any radix may include a fractional part"> #?rakudo todo 'fractionals base 16' -is(:16<dead_beef.face>, 0xDEAD_BEEF + 0xFACE / ( 16 ** 4 ), 'Fractional base 16 works' ); +is(:16<dead_beef.face>, 0xDEAD_BEEF + 0xFACE div ( 16 ** 4 ), 'Fractional base 16 works' ); # L<S02/Literals/":8<177777>"> @@ -225,7 +225,7 @@ is +":1_0<14_56>", 1456, "underscore seperators works"; is +":10<123.456>", 123.456, "base 10 decimal notation works"; is +":2<1.111>", 1.875, "base 2 decimal notation works"; - is +":16<dead_beef.face>", 0xDEADBEEF + 0xFACE / (16 ** 4), "fractional base 16 works"; + is +":16<dead_beef.face>", 0xDEADBEEF + 0xFACE div (16 ** 4), "fractional base 16 works"; for 2..36 { is +":{$_}<11>", $_ + 1, "stringified form of base $_ works"; Index: t/spec/S02-magicals/dollar_bang.t =================================================================== --- t/spec/S02-magicals/dollar_bang.t (revision 28143) +++ t/spec/S02-magicals/dollar_bang.t (working copy) @@ -34,7 +34,7 @@ ok !$called, 'The subroutine also was not called'; undefine $!; -try { 1 / 0 }; +try { 1 div 0 }; ok $!, 'Dividing one by zero sets $!'; sub incr ( $a is rw ) { $a++ };
From f76db69d1d0b7de691dbc4ba9faf51650475d36c Mon Sep 17 00:00:00 2001 From: Solomon Foster <colomon@gmail.com> Date: Mon, 31 Aug 2009 19:02:28 -0400 Subject: [PATCH] Swap the meanings of div and /, as per latest S03. Make infix:<div> use integer semantics. Contains some cleanups by Moritz Signed-off-by: Moritz Lenz <moritz@faui2k3.org> --- CREDITS | 4 ++++ build/gen_metaop_pir.pl | 2 ++ src/setting/Int.pm | 17 +++++------------ src/setting/Rat.pm | 12 +++++++++--- src/setting/Temporal.pm | 38 +++++++++++++++++++------------------- 5 files changed, 39 insertions(+), 34 deletions(-) diff --git a/CREDITS b/CREDITS index 3a4858a..97a5c54 100644 --- a/CREDITS +++ b/CREDITS @@ -296,6 +296,10 @@ N: Simon Cozens U: simon E: simon@simon-cozens.org +N: Solomon Foster +U: colomon +E: colomon@gmail.com + N: Stéphane Payrard D: Various code fixes and improvements diff --git a/build/gen_metaop_pir.pl b/build/gen_metaop_pir.pl index dc47087..92bf23d 100644 --- a/build/gen_metaop_pir.pl +++ b/build/gen_metaop_pir.pl @@ -9,6 +9,8 @@ my @ops = qw( ** 1 op * 1 op / 'fail' op + div 'fail' op + mod 'fail' op % 'fail' op x 'fail' op xx 'fail' op diff --git a/src/setting/Int.pm b/src/setting/Int.pm index 27bbcd7..2962758 100644 --- a/src/setting/Int.pm +++ b/src/setting/Int.pm @@ -49,21 +49,14 @@ multi sub infix:<*>(Int $a, Int $b) { } } -multi sub infix:</>(Int $a, Int $b) { +multi sub infix:<div>(Int $a, Int $b) { Q:PIR { $P0 = find_lex '$a' - $N0 = $P0 + $I0 = $P0 $P1 = find_lex '$b' - $N1 = $P1 - $N2 = $N0 / $N1 - $I2 = floor $N2 - $N3 = $N2 - $I2 - if $N3 != 0 goto notint - %r = '!upgrade_to_num_if_needed'($N2) - goto done - notint: - %r = box $N2 - done: + $I1 = $P1 + $I2 = $I0 / $I1 + %r = box $I2 } } diff --git a/src/setting/Rat.pm b/src/setting/Rat.pm index 9f34f9d..ba73dac 100644 --- a/src/setting/Rat.pm +++ b/src/setting/Rat.pm @@ -20,10 +20,12 @@ class Rat { $denominator = -$denominator; } my $gcd = gcd($numerator, $denominator); - $numerator /= $gcd; - $denominator /= $gcd; + $numerator = $numerator div $gcd; + $denominator = $denominator div $gcd; self.bless(*, :$numerator, :$denominator); } + + multi method perl() { "Rat.new($!numerator, $!denominator)"; } multi method Str() { "$!numerator/$!denominator"; } @@ -52,6 +54,10 @@ multi sub infix:<->(Rat $a, Int $b) { Rat.new($a.numerator - $b * $a.denominator, $a.denominator); } +multi sub infix:<->(Int $a, Rat $b) { + Rat.new($a * $b.denominator - $b.numerator, $b.denominator); +} + multi sub infix:<*>(Rat $a, Rat $b) { Rat.new($a.numerator * $b.numerator, $a.denominator * $b.denominator); } @@ -60,7 +66,7 @@ multi sub infix:</>(Rat $a, Rat $b) { Rat.new($a.numerator * $b.denominator, $a.denominator * $b.numerator); } -multi sub infix:<div>(Int $a, Int $b) { +multi sub infix:</>(Int $a, Int $b) { Rat.new($a, $b); } diff --git a/src/setting/Temporal.pm b/src/setting/Temporal.pm index c7fd3df..149c210 100644 --- a/src/setting/Temporal.pm +++ b/src/setting/Temporal.pm @@ -17,11 +17,11 @@ role Temporal::Date { method day-of-week { # returns DayOfWeek { my ( $a, $y, $m, $jd ); # algorithm from Claus Tøndering - $a = int((14 - $.month) / 12 ); + $a = (14 - $.month) div 12; $y = $.year + 4800 - $a; $m = $.month + 12 * $a - 3; - $jd = $.day + int((153 * $m + 2) / 5) + 365 * $y + int( $y / 4 ) - - int( $y / 100 ) + int( $y / 400 ) - 32045; + $jd = $.day + (153 * $m + 2) div 5 + 365 * $y + $y div 4 + - $y div 100 + $y div 400 - 32045; return ($jd + 1) % 7 + 1; } @@ -90,8 +90,8 @@ role Temporal::TimeZone::Observance { # The ISO8601 standard does not allow for offsets with sub-minute # resolutions. In real-world practice, this is not an issue. our Str method iso8601 { - sprintf "%+03d%02d", self.offset / 3600, - int( abs(self.offset) / 60 ) % 60; + sprintf "%+03d%02d", self.offset div 3600, + int( abs(self.offset) div 60 ) % 60; } method Str { self.iso8601 } @@ -117,11 +117,11 @@ role Temporal::DateTime { # This involves a whole bunch of code - see Perl 5's Time::Local our Num method epoch { my ( $a, $y, $m, $jd ); # algorithm from Claus Tøndering - $a = int((14 - $.date.month) / 12 ); + $a = (14 - $.date.month) div 12; $y = $.date.year + 4800 - $a; $m = $.date.month + 12 * $a - 3; - $jd = $.date.day + int((153 * $m + 2) / 5) + 365 * $y - + int( $y / 4 ) - int( $y / 100 ) + int( $y / 400 ) - 32045; + $jd = $.date.day + (153 * $m + 2) div 5 + 365 * $y + + $y div 4 - $y div 100 + $y div 400 - 32045; return ($jd - 2440588) * 24 * 60 * 60 + ($.time.hour*60 + $.time.minute)*60 + $.time.second; } @@ -136,21 +136,21 @@ class Time { our method gmtime( Num $epoch = time ) { my ( $time, $second, $minute, $hour, $day, $month, $year ); $time = int( $epoch ); - $second = $time % 60; $time = int($time/60); - $minute = $time % 60; $time = int($time/60); - $hour = $time % 24; $time = int($time/24); + $second = $time % 60; $time = $time div 60; + $minute = $time % 60; $time = $time div 60; + $hour = $time % 24; $time = $time div 24; # Day month and leap year arithmetic, based on Gregorian day #. # 2000-01-01 noon UTC == 2451558.0 Julian == 2451545.0 Gregorian $time += 2440588; # because 2000-01-01 == Unix epoch day 10957 my $a = $time + 32044; # date algorithm from Claus Tøndering - my $b = int((4 * $a + 3) / 146097); # 146097 = days in 400 years - my $c = $a - int(( 146097 * $b ) / 4); - my $d = int((4 * $c + 3) / 1461); # 1461 = days in 4 years - my $e = $c - int(($d * 1461) / 4); - my $m = int((5 * $e + 2) / 153); # 153 = days in Mar-Jul Aug-Dec - $day = $e - int((153 * $m + 2) / 5 ) + 1; - $month = $m + 3 - 12 * int( $m / 10 ); - $year = $b * 100 + $d - 4800 + int( $m / 10 ); + my $b = (4 * $a + 3) div 146097; # 146097 = days in 400 years + my $c = $a - ( 146097 * $b ) div 4; + my $d = (4 * $c + 3) div 1461; # 1461 = days in 4 years + my $e = $c - int(($d * 1461) div 4); + my $m = (5 * $e + 2) div 153; # 153 = days in Mar-Jul Aug-Dec + $day = $e - (153 * $m + 2) div 5 + 1; + $month = $m + 3 - 12 * $m div 10; + $year = $b * 100 + $d - 4800 + $m div 10; Temporal::DateTime.new( date => Temporal::Date.new(:$year, :$month, :$day), time => Temporal::Time.new(:$hour, :$minute, :$second), -- 1.5.6.5
Subject: Re: [perl #68898] AutoReply: [PATCH] Swap meanings of Int / Int and div
Date: Mon, 31 Aug 2009 21:44:10 -0400
To: perl6-bugs-followup [...] perl.org
From: Solomon Foster <colomon [...] gmail.com>
Download (untitled) / with headers
text/plain 1.5k
Here is an updated version of the patch, with the Temporal.t bug fixed, and Rat.perl made more sensible. Several other test failures I missed the first time have been patched, and several tests added, included a TODO test which demonstrates how this patch is not fully correct for Int div Int. On Mon, Aug 31, 2009 at 7:11 PM, perl6 via RT<perl6-bugs-followup@perl.org> wrote: Show quoted text
> Greetings, > > This message has been automatically generated in response to the > creation of a trouble ticket regarding: >        "[PATCH] Swap meanings of Int / Int and div", > a summary of which appears below. > > There is no need to reply to this message right now.  Your ticket has been > assigned an ID of [perl #68898]. > > Please include the string: > >         [perl #68898] > > in the subject line of all future correspondence about this issue. To do so, > you may reply to this message. > >                        Thank you, >                        perl6-bugs-followup@perl.org > > ------------------------------------------------------------------------- > There are two -- well, three issues with this patch that I know of: > > 1. div merely has the code for the old Int / Int, but S03 suggests the > edge cases should be a bit different. > 2. Something is broken in temporal.t, presumably indicating something > is broken in Temporal.pm. > 3. Rat.perl is probably a bit silly, considering that "N/M" should work. > > -- > Solomon Foster: colomon@gmail.com > HarmonyWare, Inc: http://www.harmonyware.com > >
-- Solomon Foster: colomon@gmail.com HarmonyWare, Inc: http://www.harmonyware.com

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Subject: Re: [perl #68898] AutoReply: [PATCH] Swap meanings of Int / Int and div
Date: Tue, 1 Sep 2009 10:58:44 -0400
To: perl6-bugs-followup [...] perl.org
From: Solomon Foster <colomon [...] gmail.com>
Download (untitled) / with headers
text/plain 435b
Hi all, This is an updated version of the patch to swap / and div. Thanks to moritz++, it mostly handles div properly now, except for failing tests in S03-operators/arith.t. Other than that this passes all spectests (once the test patch has been applied, of course). The GCD algorithm in Rat is drastically improved from the first one I sent out. -- Solomon Foster: colomon@gmail.com HarmonyWare, Inc: http://www.harmonyware.com

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

Download spectest-Rat.patch
text/plain 12.6k

Message body is not shown because sender requested not to inline it.

Download (untitled) / with headers
text/plain 117b
Applied + squashed + pushed as 39c3f4b6d5f2a702f336d33e79d23391adf36980. Cheers, and thanks for the patches. Moritz


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org