[Scilab-users] printf bug?

Stefan Du Rietz sdr at durietz.se
Sat Aug 2 22:35:25 CEST 2014


With "Scilab" here, I mean Scilab 5.5.0.

On 2014-08-02 22:30, Stefan Du Rietz wrote:
> Thank you, Leon,
> it confirms that Scilab 5.4.1 handles it correctly.
>
> But when I have LC_NUMERIC="en_DK.utf8" which means decimal comma, see
> below, Scilab is in error:
> -->msprintf("%0.2f", %pi)
>   ans  =
>   3,14
> -->msprintf("%0.2f", 3.1416)
>   ans  =
>   3,14
>
> Compare the correct handling in Python:
>  >>> "Pi with two decimals is %0.2f" % 3.1416
> 'Pi with two decimals is 3.14'
>
> Can any of the developers comment on this, or shall I report a bug?
>
> Regards
> Stefan
>
> stefan at Asus1:~$ uname -a
> Linux Asus1 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:12 UTC
> 2014 i686 i686 i686 GNU/Linux
> stefan at Asus1:~$ locale
> LANG=en_GB.UTF-8
> LANGUAGE=en_GB:en
> LC_CTYPE="en_DK.utf8"
> LC_NUMERIC="en_DK.utf8"
> LC_TIME="en_DK.utf8"
> LC_COLLATE="en_DK.utf8"
> LC_MONETARY="en_DK.utf8"
> LC_MESSAGES="en_DK.utf8"
> LC_PAPER="en_DK.utf8"
> LC_NAME="en_DK.utf8"
> LC_ADDRESS="en_DK.utf8"
> LC_TELEPHONE="en_DK.utf8"
> LC_MEASUREMENT="en_DK.utf8"
> LC_IDENTIFICATION="en_DK.utf8"
> LC_ALL=en_DK.utf8
>
>
> On 2014-07-30 07:25, Leon Bevc wrote:
>> Here is output from openSuse 13.1 and Scilab 5.4.1:
>> ---------------------------
>> lebevc at linux-xkf0:~> uname -a
>> Linux linux-xkf0.site 3.15.3-1.g42bf625-desktop #1 SMP PREEMPT
>> Wed Jul 2 09:23:08 UTC 2014 (42bf625) x86_64 x86_64 x86_64 GNU/Linux
>> ---------------------------
>> lebevc at linux-xkf0:~> locale
>> LANG=sl_SI.UTF-8
>> LC_CTYPE="sl_SI.UTF-8"
>> LC_NUMERIC="sl_SI.UTF-8"
>> LC_TIME="sl_SI.UTF-8"
>> LC_COLLATE="sl_SI.UTF-8"
>> LC_MONETARY="sl_SI.UTF-8"
>> LC_MESSAGES="sl_SI.UTF-8"
>> LC_PAPER="sl_SI.UTF-8"
>> LC_NAME="sl_SI.UTF-8"
>> LC_ADDRESS="sl_SI.UTF-8"
>> LC_TELEPHONE="sl_SI.UTF-8"
>> LC_MEASUREMENT="sl_SI.UTF-8"
>> LC_IDENTIFICATION="sl_SI.UTF-8"
>> LC_ALL=
>> ---------------------------
>> lebevc at linux-xkf0:~>  printf "%0.2f\n" 3.1416
>> bash: printf: 3.1416: invalid number
>> 0,00
>> lebevc at linux-xkf0:~> printf "%0.2f\n" 3,1416
>> 3,14
>>
>> //-----Scilab---------------------
>>
>> -->ver
>> Scilab Version:   5.4.1.1364497457
>>
>> -->x = 0.12345
>>   x  =
>>      0.12345
>>
>> -->xstr = msprintf("%0.2f", x)
>>   xstr  =
>>   0.12
>>
>>
>> 2014-07-29 22:41 GMT+02:00 Stefan Du Rietz <sdr at durietz.se
>> <mailto:sdr at durietz.se>>:
>>
>>     Leon, Can you please try it with Scilab 5.4.1 under openSUSE? And
>>     can you show its Bash output from
>>     $ locale
>>
>>     When I was running Scilab 5.4.1 under Xubuntu 12.04, printf worked
>>     OK, but also in Bash. So the question is: Why do you now get
>>     different results in Scilab and Bash?
>>
>>     And *the important point*: Why should a mathematics program handle
>>     inputs differently from outputs?
>>
>>     If one should handle decimal separators differently depending on
>>     the local language, it should be done consistently (as in Bash,
>>     even if I don't like it)!
>>
>>     One could of course have special functions or arguments to present
>>     numbers in specific local formats.
>>
>>     Stefan
>>
>>
>>
>>     On 2014-07-29 19:41, Leon Bevc wrote:
>>
>>         Strange...
>>
>>         In this case I got the same result as you on Xubuntu and
>> openSUSE:
>>
>>         [ xUbuntu 14.04.1 - 32bit / Scilab 5.5.0 / LANG=sl_SI.UTF-8 ]
>>         lebevc at book-PC:~$ printf "%0.2f\n" 3.1416
>>         bash: printf: 3.1416: neveljavno število
>>         0,00
>>         lebevc at book-PC:~$ printf "%0.2f\n" 3,1416
>>         3,14
>>
>>
>> ------------------------------__------------------------------__----------
>>
>>         [ openSUSE 13.1-64bit ; Scilab 5.4.1]
>>         lebevc at linux-xkf0:~> printf "%0.2f\n" 3.1416
>>         bash: printf: 3.1416: invalid number
>>         0,00
>>         lebevc at linux-xkf0:~> printf "%0.2f\n" 3,1416
>>         3,14
>>
>>         -->x = 0.6231166;
>>         -->xstr = msprintf("%0.2f", x)
>>            xstr  =
>>            0.62
>>
>>
>>         _________________________________________________
>>         users mailing list
>>         users at lists.scilab.org <mailto:users at lists.scilab.org>
>>         http://lists.scilab.org/__mailman/listinfo/users
>>         <http://lists.scilab.org/mailman/listinfo/users>
>>
>>
>>
>>     _________________________________________________
>>     users mailing list
>>     users at lists.scilab.org <mailto:users at lists.scilab.org>
>>     http://lists.scilab.org/__mailman/listinfo/users
>>     <http://lists.scilab.org/mailman/listinfo/users>
>>
>>
>>
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users





More information about the users mailing list