M
Mr. Burns
Hi group,
suppose I have a grid of cells of size (R,C) and coordinates (0..R-1,0..C-1) and
I'm translating pixel coordinates to grid coordinates by dividing by cell size.
Now, all works well for values >= 0, but for values < 0 I'm getting
inconsistent results.
On one platform, division of negative numbers rounds towards negative
infinity, i.e., (-1 / 10) gives -1. (this is what I want)
On another platform (solaris), rounding is towards zero, and (-1 / 10) is 0!
All numbers are plain ints.
Are both results legal? If so, is there a portable formula that will have
identical results on both kinds of platforms?
Thanks!
suppose I have a grid of cells of size (R,C) and coordinates (0..R-1,0..C-1) and
I'm translating pixel coordinates to grid coordinates by dividing by cell size.
Now, all works well for values >= 0, but for values < 0 I'm getting
inconsistent results.
On one platform, division of negative numbers rounds towards negative
infinity, i.e., (-1 / 10) gives -1. (this is what I want)
On another platform (solaris), rounding is towards zero, and (-1 / 10) is 0!
All numbers are plain ints.
Are both results legal? If so, is there a portable formula that will have
identical results on both kinds of platforms?
Thanks!