# [Scilab-users] Increase Computing Precision beyon Double // Big Integers?

5 messages
Open this post in threaded view
|

## [Scilab-users] Increase Computing Precision beyon Double // Big Integers?

 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? 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.deTechnische Universitaet Darmstadt Dept. of Electrical Engineering & Information Technology tel: +49 6151 16 75164 fax: +49 6151 16 6152 E-Mail: [hidden email] postal address: TU Darmstadt, FB 18, KOM, Rundeturmstr. 10, S320/106 D-64283 Darmstadt, Germany _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Open this post in threaded view
|

## Re: Increase Computing Precision beyon Double // Big Integers?

 28.06.2013 14:26, Sandro Hardy пишет: > 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? > > 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 > > Hi. I suppose it is common problem of representation of floating point numbers. Actually, I don't think that Matlab is more accurate. There is an interest document http://www.scilab.org/content/download/395/2850/file/ScilabTec_Keynote.pdf. Stanislav _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Open this post in threaded view
|

## Re: Increase Computing Precision beyon Double // Big Integers?

 In reply to this post by Sandro Hardy 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: [hidden email] > postal address: TU Darmstadt, FB 18, KOM, Rundeturmstr. 10, S320/106 > D-64283 Darmstadt, Germany > _______________________________________________ > users mailing list > [hidden email] > http://lists.scilab.org/mailman/listinfo/users_______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users