Math and negative number

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Math and negative number

virote328
Hi guys.

In the JACK language, how is one supposed to detect negative numbers?

I went over the Math class and noticed that the book shows examples of multiplication for positive integers.  And it got me thinking.... how does jack detect a negative number in the first place?
Reply | Threaded
Open this post in threaded view
|

Re: Math and negative number

cadet1620
Administrator
virote328 wrote
Hi guys.

In the JACK language, how is one supposed to detect negative numbers?

I went over the Math class and noticed that the book shows examples of multiplication for positive integers.  And it got me thinking.... how does jack detect a negative number in the first place?
Easiest Jack code to detect if x is negative is if (x < 0)

For Math.multiply() you don't need to worry about signs. See comment in 12.3.1.

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: Math and negative number

virote328
Oh wow, I must have left my brain in San Francisco!
 checking if it is less than zero should have been obvious.

Thanks for your help!