September 29, 2013
On 9/29/13 11:44 AM, Joseph Rushton Wakeling wrote:
> On Saturday, 28 September 2013 at 11:11:33 UTC, Joseph Rushton Wakeling
> wrote:
>> On 27/09/13 20:20, Walter Bright wrote:
>>> On 9/27/2013 6:47 AM, Joseph Rushton Wakeling wrote:
>>>> [...]
>>>
>>> Sounds like we have a new champion! Thanks, Joseph!
>>
>> I feel more like a cheerleader than a champion -- David did all the
>> hard work! ;-)
>
> Slightly bad news -- today I slipped and fell quite heavily on my right
> shoulder.  The hospital tells me there's nothing wrong that a couple of
> days' ice + painkillers won't fix, but proper two-handed typing is a bit
> painful in the meantime, so it'll probably be a few days before I get
> onto this.
>
> I wish I could say that I fell while doing cheerleading somersaults, but
> alas it was nothing so cool -- a wet paving-stone on a rainy day ... :-P

Get better soon!

Andrei
September 29, 2013
On 9/29/13, Joseph Rushton Wakeling <joseph.wakeling@webdrake.net> wrote:
> Slightly bad news -- today I slipped and fell quite heavily on my right shoulder.  The hospital tells me there's nothing wrong that a couple of days' ice + painkillers won't fix, but proper two-handed typing is a bit painful in the meantime, so it'll probably be a few days before I get onto this.
>
> I wish I could say that I fell while doing cheerleading somersaults, but alas it was nothing so cool -- a wet paving-stone on a rainy day ... :-P

I only find this amusing because I went out cycling today, it started to rain heavily, and then I fell on my *left* shoulder after crossing the street. First time I've fallen from a bike in 15 years. I really don't know why that white paint that marks the crossing part of the street is so slippery when wet.
September 29, 2013
On Sunday, 29 September 2013 at 18:44:08 UTC, Joseph Rushton Wakeling wrote:
> On Saturday, 28 September 2013 at 11:11:33 UTC, Joseph Rushton Wakeling wrote:
>> On 27/09/13 20:20, Walter Bright wrote:
>>> On 9/27/2013 6:47 AM, Joseph Rushton Wakeling wrote:
>>>> [...]
>>>
>>> Sounds like we have a new champion! Thanks, Joseph!
>>
>> I feel more like a cheerleader than a champion -- David did all the hard work! ;-)
>
> Slightly bad news -- today I slipped and fell quite heavily on my right shoulder.  The hospital tells me there's nothing wrong that a couple of days' ice + painkillers won't fix, but proper two-handed typing is a bit painful in the meantime, so it'll probably be a few days before I get onto this.
>
> I wish I could say that I fell while doing cheerleading somersaults, but alas it was nothing so cool -- a wet paving-stone on a rainy day ... :-P

That sucks, hope it get better quick for you. Hey, at least you weren't this guy: http://www.livememe.com/nwndqkh.jpg
September 29, 2013
On Sunday, 29 September 2013 at 17:59:23 UTC, Joseph Rushton Wakeling wrote:
> On 29/09/13 16:46, MrSmith wrote:
>> use -debug -gc
>
> Nope, I still get just the "floating point exception" message.

I've used for this compilation the following command:
dmd -property -debug -gc rational.d test.d -of"test.exe"

Are you catching and printing exception?
September 29, 2013
On Sunday, 29 September 2013 at 11:03:46 UTC, Joseph Rushton Wakeling wrote:
> On 28/09/13 15:56, MrSmith wrote:
>> This code fails:
>>
>> rational(0, 1) * rational(1, 1);
>>
>>
>> object.Error: Integer Divide by Zero
>> ----------------
>> 0x00408228 in int std.rational.gcf!(int, int).gcf(int, int) at
>> C:\rational\rational.d(878)
>> 0x0040820A in int std.rational.gcf!(int, int).gcf(int, int) at
>> C:\rational\rational.d(870)
>> 0x004082E7 in std.rational.Rational!(int).Rational
>> std.rational.Rational!(int).Rational.opOpAssign!("*",
>> std.rational.Rational!(int).Rational).opOpAssign(std.rational.Rational!(int).Rational)
>> at C:\rational\rational.d(235)
>> 0x004087C3 in std.rational.Rational!(int).Rational
>> std.rational.Rational!(int).Rational.opBinary!("*",
>> std.rational.Rational!(int).Rational).opBinary(std.rational.Rational!(int).Rational)
>> at C:\rational\rational.d(218)
>> 0x0040880C in _Dmain at C:\rational\test.d(8)
>> 0x0040C7EC in extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int
>> function(char[][])*).void runMain()
>> 0x0040C827 in extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int
>> function(char[][])*).void runAll()
>> 0x0040C425 in _d_run_main
>> 0x0040A064 in main
>> 0x769C33AA in BaseThreadInitThunk
>> 0x77C19EF2 in RtlInitializeExceptionChain
>> 0x77C19EC5 in RtlInitializeExceptionChain
>> ----------------
>>
>> It seems to me like gcf is not properly implemented. Also why its name is gcf
>> (greatest common factor) and not gcd (greatest common divisor)?
>
> Good catch, thank you!
>
> What compiler and options are you using to get that detailed error report?  With dmd -main -unittest -debug rational.d I get only: "Floating point exception (core dumped)".  (Albeit I'm on Linux not Windows, I guess that might make a difference.)

It's a linux thing AFAIK
September 29, 2013
On Sunday, 29 September 2013 at 21:14:09 UTC, John Colvin wrote:
> On Sunday, 29 September 2013 at 11:03:46 UTC, Joseph Rushton Wakeling wrote:
>> On 28/09/13 15:56, MrSmith wrote:
>>> This code fails:
>>>
>>> rational(0, 1) * rational(1, 1);
>>>
>>>
>>> object.Error: Integer Divide by Zero
>>> ----------------
>>> 0x00408228 in int std.rational.gcf!(int, int).gcf(int, int) at
>>> C:\rational\rational.d(878)
>>> 0x0040820A in int std.rational.gcf!(int, int).gcf(int, int) at
>>> C:\rational\rational.d(870)
>>> 0x004082E7 in std.rational.Rational!(int).Rational
>>> std.rational.Rational!(int).Rational.opOpAssign!("*",
>>> std.rational.Rational!(int).Rational).opOpAssign(std.rational.Rational!(int).Rational)
>>> at C:\rational\rational.d(235)
>>> 0x004087C3 in std.rational.Rational!(int).Rational
>>> std.rational.Rational!(int).Rational.opBinary!("*",
>>> std.rational.Rational!(int).Rational).opBinary(std.rational.Rational!(int).Rational)
>>> at C:\rational\rational.d(218)
>>> 0x0040880C in _Dmain at C:\rational\test.d(8)
>>> 0x0040C7EC in extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int
>>> function(char[][])*).void runMain()
>>> 0x0040C827 in extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int
>>> function(char[][])*).void runAll()
>>> 0x0040C425 in _d_run_main
>>> 0x0040A064 in main
>>> 0x769C33AA in BaseThreadInitThunk
>>> 0x77C19EF2 in RtlInitializeExceptionChain
>>> 0x77C19EC5 in RtlInitializeExceptionChain
>>> ----------------
>>>
>>> It seems to me like gcf is not properly implemented. Also why its name is gcf
>>> (greatest common factor) and not gcd (greatest common divisor)?
>>
>> Good catch, thank you!
>>
>> What compiler and options are you using to get that detailed error report?  With dmd -main -unittest -debug rational.d I get only: "Floating point exception (core dumped)".  (Albeit I'm on Linux not Windows, I guess that might make a difference.)
>
> It's a linux thing AFAIK

i.e. windows is more user friendly in this regard.
September 29, 2013
On Sat, Sep 28, 2013 at 03:56:26PM +0200, MrSmith wrote:
> This code fails:
> 
> rational(0, 1) * rational(1, 1);
> 
> 
> object.Error: Integer Divide by Zero
[...]

https://github.com/WebDrake/Rational/pull/1


T

-- 
Bare foot: (n.) A device for locating thumb tacks on the floor.
September 30, 2013
On 28/09/13 15:56, MrSmith wrote:
> It seems to me like gcf is not properly implemented. Also why its name is gcf
> (greatest common factor) and not gcd (greatest common divisor)?

Greatest common factor is just another term for greatest common divisor.  I don't know why David chose it, maybe because he's a scientist and liked the more traditionally formal term, maybe because gcd is typical and he wanted to avoid a clash with other implementations in other modules.

Anyway, you're right, it's not properly implemented -- it can't handle the case of one of its inputs being 0.  In fact we should have gcf(0, n) == n.

September 30, 2013
On 30/09/13 00:21, H. S. Teoh wrote:
> https://github.com/WebDrake/Rational/pull/1

Thanks, but unfortunately this pull works around the problem rather than solving it :-)

As MrSmith identified, it's gcf() that is at fault because it can't handle 0 as an input even though it should -- gcf(0, n) == gcf(n, 0) == n.

What's odd is why David didn't go with the (apparently pre-existing) std.numeric.gcd.  It doesn't currently support BigInts but it could be fixed to do so.

IIRC the consensus is that std.numeric is broken/borked beyond repair and is only waiting for a valid successor before it gets deprecated.  Was this already clear 2 years ago when David was writing std.rational?

Anyway, any preferences?  Fix std.numeric.gcd to support BigInt and kill std.rational.gcf, or fix std.rational.gcf?

September 30, 2013
On 29/09/13 21:01, Andrej Mitrovic wrote:
> I only find this amusing because I went out cycling today, it started
> to rain heavily, and then I fell on my *left* shoulder after crossing
> the street. First time I've fallen from a bike in 15 years. I really
> don't know why that white paint that marks the crossing part of the
> street is so slippery when wet.

Ack, sympathies!

Hey, the Rust people have a new release out -- does it include a weather control function?  <programming language conspiracy theory ... />

I managed to find a comfortable typing position propped up on the sofa with a couple of pillows, so hopefully I'll be more productive than planned.  Anyway, best wishes to you too for a speedy recovery!