Maths Question - Is There An Easier Answer.
Blitz3D Forums/Blitz3D Beginners Area/Maths Question - Is There An Easier Answer.
| ||
Sorry. My maths is really poor these days. I need to convert a negative number into it's positive version for use as a speed control on an analog joystick. I am currently using this: percent1#=JoyZ() percent2#=1+percent1# percent1#=1-percent2# max_speed=top_speed*percent1 Is there an easier way of making a negative number positive. My method works but something tells me you can do it in one equation and not two as I am. I know this might sound like nitpicking but silly things like this annoy me at times. Max |
| ||
Use Abs (value). |
| ||
or if you know percent 1 is -ve in the first place, use -percent1 |
| ||
If you need to reverse a direction, say from -50 to +50 or +50 to -50, then just multiply by -1. ANdy |
| ||
Wow good selection of answers! :) Thanks a lot guys. Time to play a little... Max Just changed it to: max_speed=top_speed*(Abs(JoyZ())) Now that looks a LOT nicer. And I can follow it too! :) Thanks again. |
| ||
if you know a number is negative you can donum=0-num to make it posative |
| ||
or just num=-num, slenkar :) |
| ||
num=-num? THAT simple? Damm. Oh well I will stick with what I have. Didn't realise that such a simple maths question had so many solutions... Max |
| ||
Sorry. My maths is really poor these days. Lucky for you functions exist that for this type of thing eh :-) |