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

#1 2010-05-07 17:12:50

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Smallest number

Is there a way, other than through huge amounts of if statements, to determine the smallest number of 4 variables? Thanks in advance.

Offline

 

#2 2010-05-07 17:19:08

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Smallest number

you could do it in 4 if statments
if [   {(1<2) and (1<3) and (1<4)}
set smallest to 1
]
if [   {(2<1) and (2<3) and (2<4)}
set smallest to 2
]
if [   {(3<2) and (3<1) and (3<4)}
set smallest to 3
]
if [   {(4<2) and (4<3) and (4<1)}
set smallest to 4
]

1 = variable 1
2 = variable 2
3 = variable 3
4 = variable 4
smallest = the smallest varable.

This would do it in four if statments.


You can now reach me on Twitter @johnnydean1_

Offline

 

#3 2010-05-07 19:12:04

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Smallest number

That'll work. Thanks!

Offline

 

Board footer