Re: [Haskell-cafe] Difference between div and /

2010-06-02 Thread Richard O'Keefe
On Jun 2, 2010, at 9:18 AM, Maciej Piechotka wrote: Hmm. C, Java & co.[1] seems to not have this problem. Languages that do recognise a difference between integer quotient-and-remainder and multiplicative inverse: - MATHEMATICS - Algol 60, Algol W, Algol 68 - BCPL (/ is integer division, #/

Re: [Haskell-cafe] Difference between div and /

2010-06-01 Thread Evan Laforge
> [1] By co I mean Ruby, Python, Perl and others. There are no so many > languages that do recognize the difference. % python -Q new Python 2.4.6 (#1, Aug 3 2009, 17:05:16) [GCC 4.0.1 (Apple Inc. build 5490)] on darwin Type "help", "copyright", "credits" or "license" for more information. 10 / 3

Re: [Haskell-cafe] Difference between div and /

2010-06-01 Thread Maciej Piechotka
On Tue, 2010-06-01 at 15:20 -0400, Aaron D. Ball wrote: > > > What does (stdin + stderr) `mod` stdout mean (result will be stdin). > > In my GHCi (6.12.1) with System.IO, this fails because Handle is not a > numeric type. What implementation are you using? Ups. I missed the Handle with Fd. Whi

Re: [Haskell-cafe] Difference between div and /

2010-06-01 Thread Maciej Piechotka
On Tue, 2010-06-01 at 22:40 +0200, Jonas Almström Duregård wrote: > >> One might expect a == (a/b)*b and other common arithmetic formulas to > >> hold for division? > > > Better not if one's using Float or Double. > > I figured someone would say that :) > > What about this one: > round (a/b/c) =

Re: [Haskell-cafe] Difference between div and /

2010-06-01 Thread Daniel Fischer
On Tuesday 01 June 2010 22:40:51, Jonas Almström Duregård wrote: > >> One might expect a == (a/b)*b and other common arithmetic formulas to > >> hold for division? > > > > Better not if one's using Float or Double. > > I figured someone would say that :) *g* > > What about this one: > round (a/b/

Re: [Haskell-cafe] Difference between div and /

2010-06-01 Thread Jonas Almström Duregård
>> One might expect a == (a/b)*b and other common arithmetic formulas to >> hold for division? > Better not if one's using Float or Double. I figured someone would say that :) What about this one: round (a/b/c) == round (a/(b*c)) Of course this doesn't work on Integers... /J On 1 June 2010 21

Re: [Haskell-cafe] Difference between div and /

2010-06-01 Thread Alexander Solla
On Jun 1, 2010, at 12:20 PM, Aaron D. Ball wrote: The underlying object here is a Unix file descriptor, which is just a number. In that sense, stdin is 0, stdout is 1, and stderr is 2, so this would be (0 + 2) (mod 1) = 0 Every integer is 0 (mod 1). __

Re: [Haskell-cafe] Difference between div and /

2010-06-01 Thread Aaron D. Ball
> What does (stdin + stderr) `mod` stdout mean (result will be stdin). In my GHCi (6.12.1) with System.IO, this fails because Handle is not a numeric type. What implementation are you using? The underlying object here is a Unix file descriptor, which is just a number. In that sense, stdin is 0,

Re: [Haskell-cafe] Difference between div and /

2010-06-01 Thread Daniel Fischer
On Tuesday 01 June 2010 20:26:55, Jonas Almström Duregård wrote: > One might expect a == (a/b)*b and other common arithmetic formulas to > hold for division? > > /Jonas Better not if one's using Float or Double. ___ Haskell-Cafe mailing list Haskell-Cafe

Re: [Haskell-cafe] Difference between div and /

2010-06-01 Thread Jonas Almström Duregård
One might expect a == (a/b)*b and other common arithmetic formulas to hold for division? /Jonas On 31 May 2010 14:32, Maciej Piechotka wrote: > I started to wonder what is the difference between div and / so they are > 2 separate symbols. > > div: >  Take a Integral divide and round (down) > > (

[Haskell-cafe] Difference between div and /

2010-06-01 Thread Maciej Piechotka
I started to wonder what is the difference between div and / so they are 2 separate symbols. div: Take a Integral divide and round (down) (/): Take a Fractional divide and usually round In some applications I would like to use any of those but it is not possible. Is this unification taken in