THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/06/2004 at 21:44, xxxxxxxx wrote:
Cinema 4D Version: 8.207
Platform: Windows ;
Language(s) : C++ ;
pos = pobj->GetPos();
Ok....nice so far. I snapped the grid to 1.0, so I only get full coordinates, no float values.
INT x = pos.x;
Also sounds ok.
Guess pos.x = 29.0000 ( this is what vc debug says ) Then, x = 29...in most cases, sometimes its 28!!!!!!!
On 14/06/2004 at 22:02, xxxxxxxx wrote:
Hm, SAVELONG( ) seems to solve the problem.....but why is it a problem? I always wrote int = float without thinking about it....did I not understand something essential, or whats going on?
On 17/06/2004 at 20:18, xxxxxxxx wrote:
Floating point numbers only have finite precision. Since the INT conversion just scraps the decimals, it might happen that you lose 0.9999. Use something like "INT x = pos.x + 0.5" if you want to round to the closest integer.
(Btw, please limit the number of consecutive punctuation marks to three, in order to reduce forum bandwidth use.)
On 17/06/2004 at 23:08, xxxxxxxx wrote:
Yes about the 0.9999 I did of course know, I just wondered because I set the initial objects position to 0/0/0, and move it with grid width 1.0, so decimal places should be all zero. Even if I debug it, they are zero, I thought the debug of vc shows the exact values of the variables, but not only an approximate value
On 18/06/2004 at 00:55, xxxxxxxx wrote:
you could also use Ceil() for example (or Floor() for the vice-versa result)