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

#1 2012-07-07 09:03:56

neelix087
New Scratcher
Registered: 2012-06-23
Posts: 4

two decimal points

I am trying to doing some maths but I want the results rounded to two decimal points.

I have tried using the round function, with x2 but this doubled the answer instead of knocking off all the extra digits.

Any ideas??

Thx, Neelix087

Offline

 

#2 2012-07-07 09:43:30

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: two decimal points

Use iteration:

set [reader v] to (1)
repeat until <(letter) = (.)>
set [letter v] to (letter (reader) of (answer))
add (letter (reader) of (answer))  to [answerlist v]
change [reader v] by (1)
end
repeat (2)
add (letter (reader) of (answer))to [answerlist v]
change [reader v] by (1)
end
set [answer v] to (answerlist) //should be list


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#3 2012-07-07 10:01:13

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: two decimal points

set [number v] to ((round((number)*(100)))/(100))
I believe this is what you're looking for.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#4 2012-07-07 10:09:21

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: two decimal points

AtomicBawm3 wrote:

set [number v] to ((round((number)*(100)))/(100))
I believe this is what you're looking for.

That works.

Last edited by zammer990 (2012-07-07 10:10:41)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#5 2012-07-07 16:17:57

neelix087
New Scratcher
Registered: 2012-06-23
Posts: 4

Re: two decimal points

Thanks for that guys. I will use Atomic's solution as it is a lot simpler.

Offline

 

Board footer