Re: [rust-dev] Division and modulo for signed numbers

2013-04-25 Thread Diggory Hardy
My opinion (that nobody will follow, but I still give it) is that integers should not have the / operator at all. This was one of the bad choices of C (or maybe of a previous language). Hmm, maybe, though I can imagine plenty of people being surprised at that. What really gets me though is

Re: [rust-dev] Division and modulo for signed numbers

2013-04-25 Thread Graydon Hoare
On 13-04-25 07:52 AM, Diggory Hardy wrote: My opinion (that nobody will follow, but I still give it) is that integers should not have the / operator at all. This was one of the bad choices of C (or maybe of a previous language). Hmm, maybe, though I can imagine plenty of people being surprised

Re: [rust-dev] Division and modulo for signed numbers

2013-04-25 Thread Matthieu Monrocq
I was thinking about the mapping of / and % and indeed maybe the simplest option is not to map them. Of course, having an infix syntax would make things easier: 5 % 3 vs 5 rem 3 vs 5.rem(3), in increasing order of typed keys (and visual noise for the latter ?). On the other hand, if there is no

Re: [rust-dev] Division and modulo for signed numbers

2013-04-25 Thread Erik S
Comments inline. I'm glad to see integer division getting this level of attention. Erik On 4/25/2013 11:12 AM, Matthieu Monrocq wrote: Of course, having an infix syntax would make things easier: 5 % 3 vs 5 rem 3 vs

Re: [rust-dev] Division and modulo for signed numbers

2013-04-24 Thread Eddy Cizeron
I'm a bit suprised by the suddenness of all these discussions. When I tried to call the attention on this issue 4 month ago in a thread called Arithmetics and programming, apparently nobody cared :-p Moreover, it's not just C and x86. This same choice is taken (more or less) by PowerPC, LLVM,

Re: [rust-dev] Division and modulo for signed numbers

2013-04-23 Thread Patrick Walton
On 4/23/13 7:48 AM, sw...@earthling.net wrote: Performance should be about the same when using F-division: * Performance will go up for division by constant powers of two. * Performance will stay the same for division by compile-time constants, since these are transformed by the compiler

Re: [rust-dev] Division and modulo for signed numbers

2013-04-23 Thread Erik S
On 4/23/2013 9:02 AM, Patrick Walton wrote: On 4/23/13 7:48 AM, sw...@earthling.net wrote: Performance should be about the same when using F-division: * Performance will go up for division by constant powers of two. * Performance will stay the same for division by compile-time constants,

Re: [rust-dev] Division and modulo for signed numbers

2013-04-23 Thread Graydon Hoare
On 23/04/2013 8:53 AM, Diggory Hardy wrote: I suspect (please correct me if I'm wrong) that if it wasn't for C and x86 compatibility then most people would fall into two categories: don't know/don't care, and prefer F-division. It's one of those little things like tau vs. pi which would have

Re: [rust-dev] Division and modulo for signed numbers

2013-04-23 Thread Erik S
Thanks Graydon for the detailed reply to a newbie suggestion. It looks like I'm a little too late, this ship has already sailed. You're right that it's a topic reasonable people can disagree on. Adding Lint warnings seems like a poor workaround, but maybe the reduced confusion from C developers