OK I need to know the difference between two numbers. This is easy when I need to know the difference by subtracting the smaller number from the larger number however there are many cases where I need to know the difference of the numbers when I need to subtract the smaller number from the larger number. What would be the simplest way to convert a number that ends up being negative to a positive number. Example: the difference is -26 so I want it to be converted to 26.
I will have to run an if statement to check if its negative and run the operation, I assume, unless there is an easier way.
Hi Sir
Did you try uint ??
The unsigned integer type is uint. It takes 4 bytes of memory and allows expressing integers from 0 to 4 294 967 295.
or write a little method, something like :
int MathUnsignedInt(int value) { if(value<0) { return value * -1; } return value; }
OK I need to know the difference between two numbers. This is easy when I need to know the difference by subtracting the smaller number from the larger number however there are many cases where I need to know the difference of the numbers when I need to subtract the smaller number from the larger number. What would be the simplest way to convert a number that ends up being negative to a positive number. Example: the difference is -26 so I want it to be converted to 26.
I will have to run an if statement to check if its negative and run the operation, I assume, unless there is an easier way.
MathAbs()
I saw the MathAbs() function but wasn't sure what it actually did. The description seemed a bit cryptic to me. This will make a negative number a positive number?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
OK I need to know the difference between two numbers. This is easy when I need to know the difference by subtracting the smaller number from the larger number however there are many cases where I need to know the difference of the numbers when I need to subtract the smaller number from the larger number. What would be the simplest way to convert a number that ends up being negative to a positive number. Example: the difference is -26 so I want it to be converted to 26.
I will have to run an if statement to check if its negative and run the operation, I assume, unless there is an easier way.