- Home /
Convert positive float to negative?
Hello :-) How can I convert a positive float to a negative float in C#?
Thanks, Andreas :-)
Answer by Dave-Carlile · Jul 02, 2013 at 12:13 PM
x = -x;
Nothing personal but what's the point helping with such questions. How can people with absolutely ZERO program$$anonymous$$g background be making games?! Should not we expect at least $$anonymous$$imum quality???
I agree. As I look back on this, I could probably have answered this myself or found the answer elsewhere. However, I had no knowledge of program$$anonymous$$g.. Thanks to this forum, I have become a lot smarter (also with the help from see$$anonymous$$gly self-explanatory questions like this).
Yeah man Do not give up. I just have some triggers. Sry for that. ;) Happy coding.
Answer by spoilerdo · Apr 02, 2017 at 03:54 PM
x = -Mathf.Abs(x);
I got a warning because of floatSpeed = +floatSpeed from a unity tutorial, it says that it is assigning the same variable to itself. x = +$$anonymous$$athf.Abs(x); resolves this warning, so thanks. I'm aware that this might not the best solution, but I need to move on.
Answer by SkyreGames · Jul 02, 2013 at 12:33 PM
Do you remember this from school?
1*1=1
-1*-1=1
1*-1=-1
-1*1=-1
Hehe no ;) I'm only 14, buuuuut I have managed to get a 3D game on Google Play with my little knowlegde about math, hehe ;)
@SkyreGames I take it in your village they don't have to worry about whether or not the language / compiler supports implying the operation without writing it verbatim.
Your answer
Follow this Question
Related Questions
Change a float smooth 2 Answers
Checking number against boolean 2 Answers
how to make a float value,debug as int.(or show in text UI as Int) 1 Answer
Turn float to int 2 Answers
Possible to convert a Float into an Int? 3 Answers