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

#1 2009-05-20 18:12:53

Oneandonly
Scratcher
Registered: 2009-02-07
Posts: 100+

Help Wanted!

Hey! I'm not exactly new, but I need help. I want a block that will convert negitive variables, to positive variables. I know there is one, but I just don't know which one it is.

Offline

 

#2 2009-05-20 18:14:46

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Help Wanted!

What you want is the abs block. It is a function in the math block.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2009-05-21 20:35:02

Oneandonly
Scratcher
Registered: 2009-02-07
Posts: 100+

Re: Help Wanted!

archmage wrote:

What you want is the abs block. It is a function in the math block.

Thanks! Also, do you know how to make positive negative? I tried all the functions.

Offline

 

#4 2009-05-21 20:44:34

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Help Wanted!

if (number>0){
number= number*-1
}


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#5 2009-05-21 21:15:27

Oneandonly
Scratcher
Registered: 2009-02-07
Posts: 100+

Re: Help Wanted!

archmage wrote:

if (number>0){
number= number*-1
}

Yeah... I was thinking something different. Thanks!

Offline

 

#6 2009-05-22 11:42:45

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: Help Wanted!

archmage wrote:

if (number>0){
number= number*-1
}

Or:
[blocks]<if><( <{ number }> <>> 0 )>
<set{ <{ number }> }to( (( 0 <-> <{ number }> ))
<end>[/blocks]

Both will work  smile


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

#7 2009-05-22 15:46:05

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

Re: Help Wanted!

Or if you just want to turn a positive to a negative and a negative to a positive, multiply it by negative 1.

Offline

 

#8 2009-05-23 02:51:37

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: Help Wanted!

coolstuff wrote:

Or if you just want to turn a positive to a negative and a negative to a positive, multiply it by negative 1.

Nice idea! I didn't think of that! ^^

Indeed, both Archmage's and my codes will work for positive as well as negative numbers.  smile


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

#9 2009-05-23 23:37:51

GoogleplexPlus
Scratcher
Registered: 2009-04-16
Posts: 1000+

Re: Help Wanted!

Gosh, I hope negative numbers work for you. They hate me, and so they confuse my program.
Say, can someone tell me the function of each math function?

Offline

 

Board footer