[Scilab-users] [Scilab-Dev] algebra conventions with integer types to be discussed

Stéphane Mottelet stephane.mottelet at utc.fr
Wed Sep 19 12:02:51 CEST 2018


Le 19/09/2018 à 11:46, Samuel Gougeon a écrit :
> Le 19/09/2018 à 11:24, Stéphane Mottelet a écrit :
>> Le 19/09/2018 à 11:17, Samuel Gougeon a écrit :
>>>
>>> The current implementation is not incoherent.
>> However, there are still bugs, and when trying to solve them, the 
>> question of incoherence raises. See e.g :
>>
>> --> int8(-128)/int8(-1)
>>  ans  =
>>  -128
>
> There is no bug here. The division yields 128, that then is wrapped, 
> what yields -128, since in Scilab after the int8 127, 127+1 goes to 
> -128 instead of ceiling to 127 like in Octave:
> >> int8(-128)/int8(-1)
> ans = 127
OK
>
> At first sight, Octave's result does not look more consistent than 
> Scilab's one.
> But following its own ceiling/flooring rules, yet it is consistent.
What is puzzling is that Scilab implements a *mix* of rules comming from 
different software. I am wondering about the true reason:

Scilab:

--> int8(-128)/int8(0)
  ans  =

  -128

--> int8(-128)/int8(-1)
  ans  =

  -128

Matlab:

 >> int8(-128)/int8(0)

ans =

   int8

    -128

 >> int8(-128)/int8(-1)

ans =

   int8

    127

>
> With both possible rules, wrapping or saturating ones, results may 
> appear as inconsistent. But for this example, it is not the case.
>
> Samuel
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users 
>


-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet




More information about the users mailing list