# PHP convert negative to positive number

Today, We want to share with you PHP convert negative to positive number.In this post we will show you change number to negative php, hear for How to convert a negative number to a positive number with PHP we will give you demo and example for implement.In this post, we will learn about how to convert negative value to positive in android with an example.

## PHP convert negative to positive number

There are the Following The simple About Negative number with decimals to positive number in PHP Full Information With Example and source code.

As I will cover this Post with live Working example to develop check number is positive in php, so the how to convert negative value to positive in html is used for this example is following below.

### Negative number with decimals to positive number in PHP

using PHP abs() Methods

```\$positive = abs(-985); // = 985
\$position = abs(985);  // also = 985
```

using multiple it by -1:

```\$positive = -985 * -1; // = 985
\$position =  985 * -1; // = -985
```

```\$value = -985;

if (\$value < 0)
{
\$positive = abs(\$value);
}
```

PHP: Convert a negative number into a positive number.

• step 1:A negative decimal number
• step 2:The abs function will also convert negative decimal numbers into positive decimals.
• step 3:Print out our float value onto the screen.

```//step 1:
\$ourNegativeNumber = -12.24;

//step 2:
\$positiveNumber = abs(\$ourNegativeNumber);

//step 3:
echo \$positiveNumber; //becomes 12.24
```

```\$inventory = "-12.75";
\$whole = floor(\$inventory);

if (\$whole < 0)
{
\$inventory = abs(\$inventory);
\$whole = abs(\$whole) ;
}

\$fraction = \$inventory - \$whole;

\$inventory = \$whole + ((\$fraction * 60) / 100);
echo number_format(\$inventory,2);
```

Free Live Chat for Any Issue

### PHP – Check for positive / negative numeric strings

check whether a number is positive, negative or zero using PHP

Read Also:  php trim string length - How to Extract a Substring from a String?

```<?php
\$inventory = 324; // enter any inventory of your choice here
if (\$inventory > 0) // condition for positive numbers
{
echo \$inventory . " is a positive inventory";
} else if (\$inventory < 0) // condition for negative inventory
{
echo \$inventory . " is a negative inventory ";
} else if (\$inventory == 0) // condition for zero
{
echo "You have entered zero";
} else {
echo " please enter a numeric value";
}
?>
```