May 12, 2006 #1 keak Programmer Sep 12, 2005 247 CA Hi there, Say I have something like $skip = $count / 16 where $count is some random number. How would I cast the result into an int ? I tried $skip = int ($count / 16) but it is not giving me the expected result
Hi there, Say I have something like $skip = $count / 16 where $count is some random number. How would I cast the result into an int ? I tried $skip = int ($count / 16) but it is not giving me the expected result
May 12, 2006 #2 brigmar Programmer Mar 21, 2006 414 US Then I guess I'd be asking 'what IS your expected result ?' int() truncates towards 0.... so (1.9) = 1, int(-1.9) = -1 try using 'sprintf'... Code: $nIntValue = sprintf("%d", $fDoubleValue); Upvote 0 Downvote
Then I guess I'd be asking 'what IS your expected result ?' int() truncates towards 0.... so (1.9) = 1, int(-1.9) = -1 try using 'sprintf'... Code: $nIntValue = sprintf("%d", $fDoubleValue);
May 12, 2006 #3 KevinADC Technical User Jan 21, 2005 5,070 US Give some sample data and what you expect and what you are getting that you don't expect. Then maybe someone can post a suggestion or two. Upvote 0 Downvote
Give some sample data and what you expect and what you are getting that you don't expect. Then maybe someone can post a suggestion or two.