[chuck-users] Integer divisions

Hans Aberg haberg at math.su.se
Tue Dec 15 07:07:24 EST 2009


On 15 Dec 2009, at 12:05, David Rush wrote:

> 2009/12/15 Hans Aberg <haberg at math.su.se>:
>> I find the integer divisions C rule is problematic
>
> Well integer division is a fundamentally different operation from
> rational division - which is also a different operation from
> floating-point division. Augmenting Chuck to have true rationals might
> be nice, ...

That is available in Haskell, and I have used it a lot in Hugs.

But in ChucK, I just compute rationals directly into log2 intervals -  
there isn't any need of true rational numbers if one just is going to  
play the interval.

> ...but I can't see the elimination of integer division as
> useful.
>
> Of course the real question is whether the integer remainders are
> mathematically correct (they aren't in most C-derived computer
> languages).

If one actually wants to scrap "/" for integers, the replacement would  
be functions like div(), quot(), rem(), guaranteeing the remainder is  
the correct range.

My biggest worry is having a load of numerical data that must be  
edited by hand before entering, and forgetting quietly making  
disastrous results.

   Hans




More information about the chuck-users mailing list