[Scilab-users] printf bug?

Leon Bevc lebevc at gmail.com
Wed Jul 30 07:25:14 CEST 2014


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>:

> 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
>> http://lists.scilab.org/mailman/listinfo/users
>>
>>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20140730/f7af4383/attachment.htm>


More information about the users mailing list