Jump to content

[SOLVED] mmm,


almightyegg

Recommended Posts

Worked fine for me

 

<?php
echo pow (4, 0.5);      // --> 2
echo pow (4, -0.5);     // --> 0.5
?>

 

If, on the other hand, you are trying to get pow(-4, 0.5) then it will fall over as you can't get the square root of a negative number (without going into the realm of complex numbers)

Link to comment
https://forums.phpfreaks.com/topic/64423-solved-mmm/#findComment-321216
Share on other sites

well, it is a strange thing I want it to do, if the number is positive I want it to calculate out a negative number, which I have done, and if it is already negative, then I want it to calculate out a positive number..

 

So would it be easier to remove the - from it? Also can INT columns take negatives?

Link to comment
https://forums.phpfreaks.com/topic/64423-solved-mmm/#findComment-321225
Share on other sites

well, it is a strange thing I want it to do, if the number is positive I want it to calculate out a negative number, which I have done, and if it is already negative, then I want it to calculate out a positive number..

 

So would it be easier to remove the - from it? Also can INT columns take negatives?

 

You could just do something like:

 

if($num < 0) {
//negative
}
elseif($num > 0) {
//positive
}
else {
//0
}

Link to comment
https://forums.phpfreaks.com/topic/64423-solved-mmm/#findComment-321241
Share on other sites

well, it is a strange thing I want it to do, if the number is positive I want it to calculate out a negative number, which I have done, and if it is already negative, then I want it to calculate out a positive number..

 

So would it be easier to remove the - from it? Also can INT columns take negatives?

 

You could just do something like:

 

if($num < 0) {
//negative
}
elseif($num > 0) {
//positive
}
else {
//0
}

That's what I've been doing, but the problem wasn't that, it was passing the negative number, as it can't compute it...

 

That didn't work... hmm, could I just remove the hyphen - somehow?

Link to comment
https://forums.phpfreaks.com/topic/64423-solved-mmm/#findComment-321263
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.