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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.