[Scilab-users] display of complex/not real numbers, again
Stéphane Mottelet
stephane.mottelet at utc.fr
Fri Sep 13 17:40:29 CEST 2019
Le 13/09/2019 à 17:20, Stéphane Mottelet a écrit :
>
> Le 13/09/2019 à 17:13, Samuel Gougeon a écrit :
>> Le 13/09/2019 à 16:59, Stéphane Mottelet a écrit :
>>>
>>>
>>> Le 13/09/2019 à 16:52, Samuel Gougeon a écrit :
>>>> Le 13/09/2019 à 14:22, Stéphane Mottelet a écrit :
>>>>>
>>>>> However, as I already said it elsewhere, some glitches such as the
>>>>> following one do occur (see the display of whole x)
>>>>>
>>>>> --> x=1:0.1:2
>>>>> x =
>>>>> 1. 1.1 1.2 1.3 1.4 1.5 1.6 1.7000000 1.8 1.9 2.
>>>>>
>>>>
>>>> I agree with Christophe. This output is OK for me. Aestheticism
>>>> must be encouraged provided that it does not truncate or downgrade
>>>> the information.
>>>>
>>>> About padding every number: Not OK. This would kill one of the
>>>> assets of the "v" format: its compacity.
>>>>
>>>> About the fact that 1.7 can't be exactly encoded: It is very
>>>> surprising for a so limited decimal number. But OK. I am also quite
>>>> surprised that, in this series, only 1.7 can't be exactly encoded.
>>>>
>>> bitstring allows to see that only 1, 1.5 and 2 are exactly encoded
>>>
>>
>> So, question: Why 1.1 1.2 1.3 1.4 1.6 1.8 and 1.9 are displayed
>> without trailing 0, while 1.7 is?
The actual algorithm in addDoubleValue() in tostring_common.cpp is quite
simple. The decimal representation of the number x to display is first
determined up to the current format settings. The obtained string is
then converted back to a double y with atof(). If x and y differ, then
trailing zeros can eventually be displayed if the settings allow it.
>> The argument/explanation according to which 1.7 can't be exactly
>> encoded does not tell all...
>
> By using format(24) in current Scilab version you will have the
> explanation :
>
> --> (1:0.1:2)'
> ans =
>
> 1.
> 1.100000000000000088818
> 1.199999999999999955591
> 1.300000000000000044409
> 1.399999999999999911182
> 1.5
> 1.600000000000000088818
> 1.700000000000000177636
> 1.8
> 1.9
> 2.
>
> You have (1.700000000000000177636-1.7) >= %eps but for the others the
> difference is lower
>
>
>>
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/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