[Scilab-users] Increase Computing Precision beyon Double // Big Integers?
Mathieu Dubois
mathieu.dubois at limsi.fr
Fri Jun 28 11:05:02 CEST 2013
On 2013-06-28 10:26, Sandro Hardy wrote:
> Hello everyone,
>
> is it there a way to increase the computing precision in Scilab
> beyond the regular "double precision"?
>
> In Scilab this example gives me a wrong result:
> -->290017/10000
> ans =
>
> 29.001699999999999590727
>
> R is more accurate (Matlab also):
>> 290017/10000
> [1] 29.0017
>
> In R I can even increase the precison:
>> options(digits=10)
>
> Is this also possible with Scilab?
>
On my computer (scilab 5.3.3, ubuntu 12.04)
-->290017/10000
ans =
29.0017
The R "digits" option only change the number of digits that are
displayed not the precision of the computation. So under R:
> options(digits=22)
> 290017/10000
[1] 29.00169999999999959073
The scilab equivalent of option(digit = ...) is format (I guess that
youhave changed that in your example).
-->format(24)
-->290017/10000
ans =
29.00169999999999959073
Similarly in Matlab:
>> format LONG
>> 290017/10000
ans =
29.001700000000000
I think that R and Matlab use the native double type (as scilab) so
precision is the same. The fact that your operation is wrong is a
fundamental limit of floating point representation.
There is a scilab toolbox for multiprecision computing
(http://forge.scilab.org/index.php/p/mpscilab/) but I don't know the
state of it. It probably solves the big integers problem.
> Similar question for big numbers, is there a "standard" solution for
> this (BigIntegers)?
>
> In Scilab:
> -->a=635037699992127443
> a =
>
> 635037699992127488.
>
> -->b=635037699992127444
> b =
>
> 635037699992127488.
>
> -->a-b
> ans =
>
> 0.
>
> I would expect a warning, but I get get a wrong result. At least the
> output gives me the hint, that the variable was not set accurately.
>
> The solution is called bigz in R (VPI in Matlab) and work like this:
>
>> a=as.bigz('635037699992127443');
>> b=as.bigz('635037699992127444');
>> a-b
> Big Integer ('bigz') :
> [1] -1
>
> Thanks in advance for any hints.
>
> Sandro
>
>
> --
> Sandro Hardy, M.Sc.
>
> Multimedia Communications Lab (KOM)
> http://www.kom.tu-darmstadt.de
> Technische Universitaet Darmstadt
> Dept. of Electrical Engineering & Information Technology
> tel: +49 6151 16 75164 fax: +49 6151 16 6152
> E-Mail: Sandro.Hardy at kom.tu-darmstadt.de
> postal address: TU Darmstadt, FB 18, KOM, Rundeturmstr. 10, S320/106
> D-64283 Darmstadt, Germany
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
More information about the users
mailing list