Printing a boolean value
Reported by iai
WISH DESCRIPTION:
----------------
Currently the way to print a boolean value is unintuitive.
My suggestion is to implement one of these two:
(1) 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. For example, mprintf("%b\n", %T), where %b is for boolean, may print a string "%T".
(2) A boolean value may be implicitely converted to an integer value as in C, which is widely recognized practice. In this case, mprintf("%i\n", %T) shall print "1".
This above suggestion is based on the email communication on Scilab mailing list:
https://www.mail-archive.com/users@lists.scilab.org/msg01853.html
ERROR LOG:
----------
HOW TO REPRODUCE THE BUG:
-------------------------
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)
Workarounds are:
mprintf("%i\n", bool2s([%T; %F]))
1
0
mprintf("%s\n", string([%T; %F]))
T
F
(Scilab 5.4.1)
OTHER INFORMATION:
------------------
Edited by Vincent COUVERT