May 12, 2006 #1 keak Programmer Joined Sep 12, 2005 Messages 247 Location 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 Joined Mar 21, 2006 Messages 414 Location 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 Joined Jan 21, 2005 Messages 5,070 Location 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.