This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-06-26 15:38:14

stefanoquintarelli
New Scratcher
Registered: 2012-06-26
Posts: 1

floating point accuracy problem

Hello
I am trying to teach my daughter how to calculate Pi by calculating the area of a circle of radius 1, adding up surfaces of sections.
I need the sqrt function and I find that it always trims the number to the first digit after the comma.
is there a way to increase the accuracy of floating point variables and functions in scratch ?
thanks!

Offline

 

#2 2012-06-26 16:01:51

MathWizz
Scratcher
Registered: 2009-08-31
Posts: 1000+

Re: floating point accuracy problem

I can't reproduce this. What number is it trimming?


http://block.site90.net/scratch.mit/text.php?size=30&text=%20A%20signature!&color=333333

Offline

 

#3 2012-06-26 17:05:24

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: floating point accuracy problem

I think I might know the issue--output. The output trims it, but the roots themself are accurate. An example is my project, Computing Pi


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#4 2012-06-27 06:14:40

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: floating point accuracy problem

(join (value) [ ])
This should prevent auto-rounding.  smile


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

#5 2012-11-28 07:26:55

jinggle
New Scratcher
Registered: 2010-09-21
Posts: 5

Re: floating point accuracy problem

Sweet, some one actually looked at my floating point project, and shared the technique! Makes it all worth it.

Offline

 

Board footer