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

#1 2012-05-21 03:16:44

tibstar
New Scratcher
Registered: 2012-01-27
Posts: 5

using arithmetic

Hi,

I'm very new to sense, I have a question about working out percentage differences.

If i have a list of numbers, how can i work out the percentage difference between two numbers?

I have tried to simply put a variable into the equation, for example:

variable / 100 x 40  but the result is 0.0

if anyone can point me in the right direction, if appreciate it

Offline

 

#2 2012-05-21 04:24:59

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: using arithmetic

This?

set [percentagedifference v] to ( ( (variable2) - (variable1) ) / (variable1) )


http://trinary.tk/images/signature_.php

Offline

 

#3 2012-05-21 05:14:57

tibstar
New Scratcher
Registered: 2012-01-27
Posts: 5

Re: using arithmetic

I think i need this:

Set percentageDifference to A - B / B x 100

I have tried this, but the number it throws out is the same number

(btw A is from an item in a list, can you use list items in equations?

ahh i am very confused with this

Offline

 

#4 2012-05-21 05:49:46

tibstar
New Scratcher
Registered: 2012-01-27
Posts: 5

Re: using arithmetic

Basicaly i need to work out percentage increases or decreases of incoming values

Offline

 

Board footer