Converting positive decimals into negative decimals and vice versa.
The negateDecimal class can be accessed in the src folder or by clicking here.
Important
The negateDecimal class must be inside your project before any methods can be used.
// One way of getting the negateDecimal class inside your project. This requires the class to be in the same folder as the file using this code.
NegateDecimal negateDecimal = new NegateDecimal();
Returns a negative version of a positive double and vice versa.
negateDecimal.negateDouble(6.0); // Returns -6.0 as a double.
negateDecimal.negateDouble(156.415); // Returns -156.415 as a double.
negateDecimal.negateDouble(0.0); // Returns 0.0 as a double.
negateDecimal.negateDouble(-9.0); // Returns 9.0 as a double.
negateDecimal.negateDouble(-16.5); // Returns 16.5 as a double.
Returns a negative version of a positve float and vice versa.
negateDecimal.negateFloat(6.0f); // Returns -6.0 as a float.
negateDecimal.negateFloat(156.415f); // Returns -156.415 as a float.
negateDecimal.negateFloat(0.0f); // Returns 0.0 as a float.
negateDecimal.negateFloat(-9.0f); // Returns 9.0 as a float.
negateDecimal.negateFloat(-16.5f); // Returns 16.5 as a float.
This repository contains the MIT license. You must give credit if you are going to use its source code.