Hi guys,
I'm not sure if such a functio exists - but is it possible to have a number rounded up to 0 if and only if it is negative?
Thanks in advance,
Rob.
Rounding negative
Moderator: General Moderators
- PHPHorizons
- Forum Contributor
- Posts: 175
- Joined: Mon Sep 14, 2009 11:38 pm
Re: Rounding negative
Whereas, if the number were positive, it would just leave the number unchanged? I don't believe so.
- ColonelSandersLite
- Forum Commoner
- Posts: 35
- Joined: Sun May 09, 2010 1:32 am
Re: Rounding negative
Simple:
You could even make a custom function to do it if you so pleased, though it may not be worth the effort, because this isn't something you'll need to do a lot really.
Code: Select all
if ($number < 0) {$number = 0;};
Re: Rounding negative
Code: Select all
$number = max($number, 0);