Reputation: 189
this is probably ridiculously simple but I'm not sure how to do this properly and couldn't find anything - if I have a positive decimal number, e.g 0.04, what's the best way to cast this to a negative value in PHP?
Upvotes: 1
Views: 5682
Reputation: 360922
$var = 0.04;
$neg = -$var; // easiest
$neg = -1 * $var; // bit more explicit
$neg = 0 - $var; // another version
Upvotes: 8