Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 15, 2009, 04:18 PM   #1
neil.b
macrumors member
 
Join Date: Nov 2008
Converting a number to IEEE Extended

I'm trying to read/write sample rate information from AIFF files and came across these two handy functions for converting to/from IEEE 80-bit Extended number format;

http://www.onicos.com/staff/iz/formats/ieee.c

However, when I use the function the numbers don't come out right. For example, the bytes for a 44100Hz sample is (if you read it in a hex editor);

Code:
40 0D AC 44 00 00 00 00 00 00
but if I use the ConvertToExtended function like this (I put the casts in just in case but it actually has no effect on the result);

Code:
ConvertToIeeeExtended((double)44100, (char *)byteBuffer);
and then read the numbers stored in byteBuffer I get;

Code:
40 0E AC 44 00 00 00 00 00 00
Now I only vaguely understand the conversion process so I'm having a hard time working through the function to find out why it's not coming out correct. Can anyone decode the function (in the link) and suggest why, maybe, it won't work in Objective-C? I copy-and-pasted it straight into my code and it compiles fine.

Or alternatively, is there a way of working with IEEE 80-bit Extended numbers in the iPhone API?

Thanks,

Neil
neil.b is offline   0 Reply With Quote
Old Jan 15, 2009, 05:17 PM   #2
neil.b
Thread Starter
macrumors member
 
Join Date: Nov 2008
Might have answered my own question. If you use a "double long" you can use a (char *) to access the first 10 bytes and it gives you the correct result, in reverse order.

As for the "error" I was seeing, it was in fact correct (so the function I found and linked to actually works too) - for some reason the audio properties of the file were being reported incorrectly in the sound editor I was using. Doh!

Last edited by neil.b; Jan 15, 2009 at 06:15 PM. Reason: Missed a bit
neil.b is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Using 2nd router to extend signal MasterMatt Mac OS X Server, Xserve, and Networking 3 Oct 5, 2011 10:34 AM
Convert Input Text to Number in Actionscript 2.0 Rodie1952 Web Design and Development 4 Nov 13, 2009 09:17 AM
Iphone app to change all none "+66" numbers to "+66" numbers kenneth.parmar iPhone and iPod touch Apps 2 Nov 12, 2009 11:09 AM
Taking US Iphone 3G to UK and changing phone number to local UK number for 5 months twink1etoes619 iPhone 7 Jan 30, 2009 02:07 AM
An easy way to convert phone numbers? cstromme iPhone Tips, Help and Troubleshooting 0 Sep 12, 2007 08:03 AM


All times are GMT -5. The time now is 02:16 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC