stijn0713 Posted June 26, 2012 Share Posted June 26, 2012 Can i assign an infinite amount to a variable so that it will never be picked if i check it against 'closest to zero' condition? Link to comment https://forums.phpfreaks.com/topic/264828-assigning-infinite-amount-to-variable/ Share on other sites More sharing options...
Andy-H Posted June 26, 2012 Share Posted June 26, 2012 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 https://forums.phpfreaks.com/topic/264828-assigning-infinite-amount-to-variable/#findComment-1357178 Share on other sites More sharing options...
stijn0713 Posted June 26, 2012 Author Share Posted June 26, 2012 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 https://forums.phpfreaks.com/topic/264828-assigning-infinite-amount-to-variable/#findComment-1357182 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.