Skip to main content

Accurately Converting NSString to GLFloat - iPhone



Say I have some vertice values which I am reading into my app as a NSString :





-7501.6 -6198.2 834.939 -5547.66 -6348.32 2122.65





The values in the source are always 6 figures in length.





I need to pass these exact values to OpenGL. If I try to cast as a float (using NSString floatValue) then, as expected, I get an approximate value for each float due to the inexact nature of a float :





-7501.600098, -6198.200195, 834.939026 -5547.660156, -6348.319824, 2122.649902





Can anyone suggest a way that I can get these values into OpenGL and retain their exact initial integrity ?





Thank you.


Comments

  1. See 'Getting Numeric Values' paragraph from NSString Documentation (Apple).

    [str floatValue];
    [str doubleValue];

    ReplyDelete
  2. maybe this: NSString to NSNumber could help.

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?