Can specify data type of CONST in the “Xcos -> Set Context”?

I use CONST block in the Xcos, and it corresponds to the CONSTANT under “Xcos → Set Context".
My question is: All the CONSTANTS under “Xcos → Set Context” are considered as “Int32” as default (Please correct me if wrong). Is it possible for me to specify the data type of CONSTANT, such as int(8) or bool, so that I don’t need datatype conversion block in the Xcos diagram?

Hello, welcome to Scilab’s Discourse !

By default all variables defined by a simple assignment of a decimal value are stored as double precision floating point values (IEEE 754). If you need a particular integer type just use a converting function (see int8 - Conversion to one byte integer representation), e.g.:

x = int8(1);

For a boolean you can directly assign %t or %f.

S.

Hello Mottelet,

Thank you for the help.

It works by using A = int8(6) as your instruction in the SciLab environment, however, I have a problem when using A = int8(6) in the “Xcos → Simulation → Set Context”
environment. For example, I write A = int8(6) in the “Xcos → Simulation → Set Context” , and place a CONST block to connect the variable A, it shows error as following photo.

After further looking, I suspect that A = int8(6) is accepted by Xcos, but the CONST only take double floating point. My question is: Is there similar CONST can take int8? If not, how to use the variable of int8 assigned in the “Set Context” environment?

I tried attached the test zcos file, but I was told new user are not allowed attachment.

Regards,
Junying

Hello,

There should be no error if you set everything as you said. Try with the following diagram (created with Scilab 2025.0.0):
c.zcos (2.1 KB)

Hello mottelet,

Thank you for the example.

And it works. It also helped me find my error. I use CONST block and you use CONST_M block. After using CONST_M, my diagram works.

Thank you very much .
Regards,
Junying