jqgrid - What's the difference between 2 lines in PHP? -
i have found in jqgrid server side php example next line
$start = $limit*$page - $limit; // not put $limit*($page - 1) what's difference between
$start = $limit*$page - $limit; and
$start = $limit*($page - 1); why authors not recommend second way ?
i suspect numerical math issue. suppose $page huge, in 6.02e231.
($page - 1) = 6.02e231 (the exact same floating point representation),
$limit*($page - 1) = $limit*$page from point of view of processor. compare
$limit*$page = [some huge value] $limit*$page - $limit = [subtraction of 2 huge values] which yield different result, more accurate "minus one" notation.
so although in perfect world of mathematics, 2 notations equal, in non-perfect world of computing, first 1 more prone 'catastrophic cancellation' (wiki that) second.
Comments
Post a Comment