Jump to content

assigning infinite amount to variable


stijn0713

Recommended Posts

No there is no 'infinite' rvalue in PHP.

 

 

function unsigned($int)
{
   return ($int < 0) ? (~(int)$int) + 1 : (int)$int;
}
$i = 25;
$n = -55;
$i = unsigned($n) + 1;
if ( $i < unsigned($n) )
{
   // this effectively does what you ask for, but what's the point?
}

Link to comment
Share on other sites

i have a 2 dim array where i divide column a by column b. I need the key of b where the division a/b is the closest to zero.

 

So i first check if b is > 0, (otherwise i can't divide), if not, i want to assign 'infinite' as result of the division. Because if i don't store anything, i don't know how to keep track of the key where i'm currently at.

 

So i assign each division to an array, and if b < 0, i tried to assign -log(0) (as 'infinite'). But if i check for the lowest value in that array than, it doesn't appear to work.

 

With this is mind, maybe it clears out the problem a little bit, because i don't see how your function could help me.

 

thanks in advance

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.