[Scilab-users] xstring + format decimal number.

Dang Ngoc Chan, Christophe Christophe.Dang at sidel.com
Fri Mar 26 09:15:51 CET 2021


Hello,

> De : Marcus Vinicius P. de Souza
> Envoyé : jeudi 25 mars 2021 18:20
>
> Mp=54.5666666
> [...]
> I want only: Mp=54.56%
> How do I do?

I suggest o use floor() (truncate) or round(), e.g.

xstring(1, 1, '$\LARGE Mp={' + string(0.01*floor(100*Mp)) + '}\%$')

or use msprintf() (rounding), e.g.

xstring(0, 1, '$\LARGE Mp={' + msprintf("%2.2f", Mp) + '}\%$')

HTH

Regards


--
Christophe Dang Ngoc Chan
Mechanical calculation engineer

General
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.



More information about the users mailing list