[Scilab-users] printing a boolean value

Iai Masafumi ax iai at axelspace.com
Sat Mar 29 14:21:20 CET 2014


 > -->mprintf("%s\n", string([%T; %F]))
I am amazed to get my question answered after three month! Thanks, Stefan.

Still, I want to see Scilab become more intuitive.

If Scilab considers the boolean type is completely different type than 
integer, I think it should have a format specifier for the boolean type, 
that can be given to mprintf.

Or a boolean value may be implicitely converted to an integer value as 
in C, which is widely recognized practice.


Iai


(2014/03/28 20:56), Stefan Du Rietz wrote:
> On 2013-12-21 12:48, Stefan Du Rietz wrote:
> --------------------
>> On 2013-12-21 12:29, Iai Masafumi ax wrote:
>> --------------------
>>> How do I print a boolean value? Any of these gave me an error:
>>>
>>> mprintf("%d\n", %T)
>>> mprintf("%i\n", %T)
>>> mprintf("%o\n", %T)
>>> mprintf("%u\n", %T)
>>> mprintf("%x\n", %T)
>>> mprintf("%X\n", %T)
>>> mprintf("%e\n", %T)
>>> mprintf("%E\n", %T)
>>> mprintf("%f\n", %T)
>>> mprintf("%g\n", %T)
>>> mprintf("%G\n", %T)
>>>
>>> Thanks,
>>> Iai
>>
>> I usually do it like this:
>>
>> -->mprintf("%i\n", bool2s([%T; %F]))
>> 1
>> 0
>>
>> Regards /Stefan
>
> Eventually I realized how to do it exactly like we want it. string() is
> a very usable built-in function:
>
> -->mprintf("%s\n", string([%T; %F]))
> T
> F
>
> Stefan
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users




More information about the users mailing list