# absint( mixed\$maybeint ): int

Converts a value to non-negative integer.

## Parameters

`\$maybeint`mixedrequired
Data you wish to have converted to a non-negative integer.

## Return

int A non-negative integer.

## Source

``````function absint( \$maybeint ) {
return abs( (int) \$maybeint );
}
``````

## User Contributed Notes

As to math and floating numbers there are results to consider when using `absint()`. Here are some tests.

``````echo '<ul>
<li>0      returns '. absint( 0 ) . '</li>
<li>1      returns '. absint( 1 ) . '</li>
<li>-1     returns '. absint( -1 ) . '</li>
<li>-1 + 1 returns '. absint( (-1 + 1) ) . '</li>
<li>1 * -1 returns '. absint( (1 * -1) ) . '</li>
<li>1 / -1 returns '. absint( (1 / -1) ) . '</li>
<li>1 - 1  returns '. absint( (1 - 1) ) . '</li>
<li>0 * -1 returns '. absint( (0 * -1) ) . '</li>
<li>0 / 1  returns '. absint( (0 / 1) ) . '</li>
<li>0 - 1  returns '. absint( (0 - 1) ) . '</li>
<li>0.99 * 1  returns '. absint( (0.99 * 1) ) . '</li>
<li>1.99 * 1  returns '. absint( (1.99 * 1) ) . '</li>
<li>0.99 / 1  returns '. absint( (0.99 / 1) ) . '</li>
<li>1.99 / 1  returns '. absint( (1.99 / 1) ) . '</li>
</ul>';``````

Prints:
``` 0 returns 0 1 returns 1 -1 returns 1 -1 + 1 returns 0 1 * -1 returns 1 1 / -1 returns 1 1 - 1 returns 0 0 * -1 returns 0 0 / 1 returns 0 0 - 1 returns 1 0.99 * 1 returns 0 1.99 * 1 returns 1 0.99 / 1 returns 0 1.99 / 1 returns 1 ```

You must log in before being able to contribute a note or feedback.