views:

242

answers:

1

Hi guys!

Here is my code:

    frame = _pageContentView.frame;
    NSLog(@"%f; %f; %f; %f;", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
    frame.size.height = pageContentView.frame.size.height;
    NSLog(@"%f; %f; %f; %f;", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
    _pageContentView.frame = frame;
    NSLog(@"%f; %f; %f; %f;", _pageContentView.frame.origin.x, _pageContentView.frame.origin.y, _pageContentView.frame.size.width, _pageContentView.frame.size.height);

And the NSLog outputs these values:
0.000000; 0.000000; 317.648956; 0.000000;
0.000000; 0.000000; 317.648956; 768.000000;
0.000007; 0.000004; 317.648956; 768.000000;

Can you see? In the last row the x and y coordinates are a bit crazy... Where do these number come frome? What's the problem here?

+3  A: 

Some math is done to your zeroes; turning them, effectively, into 0.change. Note, however, that the irregularity represents a drift of 0.0007%. It's really nothing to worry about. You can safely ignore anything after the first digit after the period, or two digits if you are moving the views around alot.

Williham Totland
But, what math is done?
Infinity
Who knows? Who cares? It might be as simple as stuff being shunted back and forth from double to float; or crud left from previous iterations in the FPU. The discrepancy is *utterly* irrelevant, and should simply be ignored. (0.000007 represents 0.0007%, or one 7 one hundred thousandths of a pixel; that is to say, something like 35 nanometers).
Williham Totland
Computers can't do real math. All floating point numbers have built variability owing the compromises that computers have to make in processing math especially in the case of irrational numbers. There's a famous paper on the subject. http://docs.sun.com/source/806-3568/ncg_goldberg.html
TechZen