[Scilab-users] {EXT} lcm() output type: how to avoid overflowing and get an actual result?
Samuel Gougeon
sgougeon at free.fr
Wed Mar 15 18:02:08 CET 2017
Hello Christophe,
Thanks for your contribution:
Le 15/03/2017 à 17:29, Dang Ngoc Chan, Christophe a écrit :
>> My (slight) preference would be to cast the result always into the decimal class
> This sounds reasonable.
>
> But the result could also be converted to the format that is the "closest and suitable" from the input format.
>
> I mean: the user forced a format that is not floating point number for a reason of his/her own;
> When it is possible, we should respect this choice.
>
> So if the input is in uint8, the result could be computed in floating point number
> then converted to uint8 if possible, or uint# if it is too large, or even kept as floating point number when required.
Yes, it is possible to do that. But the main "problem" of this
implementation would be that the output type would be unpredictable.
So, do we prefer such an unpredictable type, that despite it is
optimized could still fail being lossless,
or do we prefer a fixed output type, by the way the same as for decimal
operands, that will be most
often lossless, and would already be much better than the current
implementation (that is everything but lossless :/)?
I think that if a user wants to use big integers to get accurate
results, using an arbitrary accuracy module would be mandatory.
> Don't know how heavy this is on a big matrix (a user probably select uint# to spare memory).
IMO memory space is no longer really a problem in Scilab 6 [1].
Regards
Samuel
[1] About this topic, we could have expected from Scilab 6.0 to
implement the wish
http://bugzilla.scilab.org/12789 aiming to store each boolean in 1 byte
instead of 4.
But this is another thread.
More information about the users
mailing list