alin19 Posted January 9, 2008 Share Posted January 9, 2008 what is the comand to eliminate the last number from a number $a= $a /10? and how i get that number that i took out? $x=$a .... 10 why whis comand dosn't work? if (0.0101< $a<=0.2000) { } Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/ Share on other sites More sharing options...
trq Posted January 9, 2008 Share Posted January 9, 2008 Sorry, your explination is not clear. What is it your after? Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434466 Share on other sites More sharing options...
asmith Posted January 9, 2008 Share Posted January 9, 2008 that would be % command : $a = 26 % 10 // $a = 6 $a = 675 % 10 // $a = 5 why whis comand dosn't work? if (0.0101< $a<=0.2000) { } i don't think you could do whole in one that should be : if ( $a > 0.0101 && $a <= 0.2000) // $$ mean and , you can use and too . { } Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434468 Share on other sites More sharing options...
alin19 Posted January 9, 2008 Author Share Posted January 9, 2008 yes this is good, but i need one more, from 52 i need to get 50 from 58 also 50 Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434470 Share on other sites More sharing options...
asmith Posted January 9, 2008 Share Posted January 9, 2008 i dont' know any function for that , BUT why don't you sub that number : $a = 52; $b = $a % 10; $c = $a - $b; // $c will be 50 . Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434471 Share on other sites More sharing options...
alin19 Posted January 9, 2008 Author Share Posted January 9, 2008 yes, i think that will work the same, 10x Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434473 Share on other sites More sharing options...
rajivgonsalves Posted January 9, 2008 Share Posted January 9, 2008 or <?php $a = 58; echo ((int) ($a/10))*10; ?> Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434477 Share on other sites More sharing options...
alin19 Posted January 9, 2008 Author Share Posted January 9, 2008 my numbers are in format 0.0000 4 zecimals not (INT) Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434486 Share on other sites More sharing options...
rajivgonsalves Posted January 9, 2008 Share Posted January 9, 2008 from 52 i need to get 50 from 58 also 50 if you give examples maybe I could fish something out Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434487 Share on other sites More sharing options...
alin19 Posted January 9, 2008 Author Share Posted January 9, 2008 if (isset ($b)) { if ($b=='rgbs' OR $b=='dlbs' || $b=='odbs' || $b=='xmbs' || $b=='xdeal' ||$b=='RGBS' || $b=='DLBS' || $b=='ODBS' || $b=='XMBS' || $b=='XDEAL' ) { if ($a<=0.0100) { } if (0.0101< $a AND $a<= 0.2000) { $h=number_format($xmax % 10, 4, '.', '') $xmax=number_format($xmax-$h; 4, '.', '') } if (0.2001<$a AND $a<=1.0000) { } if (1.0001<$a AND $a<=5.0000) { } if (5.0001<$a AND $a<=20.0000) { } if (20.0000<$a) { } } } this is what i have until now, it is complicated, not tehnical but work, i will have 3 numbers, x xmin xmax, xmin=x-15/100*x xmax=x+15/100*x and those steps: x <0.0100 here x, xmin , xmax can grow with 0.0001 0.0101<x<0.2000 here x, xmin , xmax can grow with 0.0010 0.2001<x<1,0000 here x, xmin , xmax can grow with 0.0100 1.0001<x<5.0000 here x, xmin , xmax can grow with 0.0500 5.0001<x<20.0000 here x, xmin , xmax can grow with 0.1000 x<20.0000 here x, xmin , xmax can grow with 0.5000 the big problem is when for example x= 0.1900 because xmax will go into the other step, i'm working on it Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434496 Share on other sites More sharing options...
alin19 Posted January 9, 2008 Author Share Posted January 9, 2008 if (0.0101< $a AND $a<= 0.2000) { $h=number_format($xmax % 10, 4, '.', '') $xmax=number_format($xmax-$h; 4, '.', '') if ($xmax >0.2000) { $h1=number_format($xmax % 10, 4, '.', '') $xmax=($xmax-$h1) /10 $h2=number_format($xmax % 10, 4, '.', '') $xmax=(($xmax-$h2) /10)*100 } if ($xmin <= 0.101) { } something like this i think it will work, still working on it Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434502 Share on other sites More sharing options...
alin19 Posted January 9, 2008 Author Share Posted January 9, 2008 $a= 0.0501 $b=$a %10; $c=$a-$b; will this work if those won't be int numbers? Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434530 Share on other sites More sharing options...
alin19 Posted January 9, 2008 Author Share Posted January 9, 2008 if (0.0101< $x AND $x<= 0.2000) { if ($xmax <= 0.2000) { $xmax=$xmax*10000; $h=$xmax % 10; $xmax=$xmax - $h; $xmax=$xmax/10000; $xmax= number_format($xmax, 4, '.', ''); } if ($xmin >0.0101) { $xmin=$xmin*10000; $j=$xmin % 10; $xmin=$xmin-$j; $xmin=$xmin/10000; $xmin= number_format($xmin, 4, '.', ''); } if ($xmax >0.2000) { $xmax=$xmax*10000; $h1=$xmax % 10; $xmax=($xmax-$h1) /10; $h2=$xmax % 10; $xmax=(($xmax-$h2) /10)*100; $xmax=$xmax/10000; $xmax= number_format($xmax, 4, '.', ''); } if ($xmin <= 0.101) { } } i've done this; when all of $x, $xmin and $xmax are between 0.0101 and 0.2000 all it's ok, but when $x is 0.1900 i get: MAX 0.2300 good x 0.1900 good MIN 0.1421 bad Quote Link to comment https://forums.phpfreaks.com/topic/85159-dividing-a-number/#findComment-434572 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.