Floating point formats: Java/C/C++, PPC and Intel platforms

Hi everyone
Where can I find out about the various bit formats used for 32 bit floating numbers in Java and C/C++ for both Mac hardware platforms?
I'm developing a Java audio application which needs to convert vast quantities of variable width integer audio samples to canonical float audio format. I've discovered that a floating point divide by the maximum integer value gives the correct answer but takes too much processor time, so I'm trying out bit-twiddling in C via JNI to carve out my own floating point bit patterns. This is very fast, however, I need to take into account the various float formats used on the different platforms so my app can be universal. Can anyone point me to the information?
Thanks in advance.
Bob

I am not sure that Rosetta floating point works the same as PPC floating point. I was using RealBasic (a PPC basic compiler) and moved one of the my compiled applications to a MacBook Pro and floating point comparisons that had been exact on the PPC stopped working under Rosetta. I changed the code to do an approximate comparison (i.e. abs(a -b) < tolerance) and this fixed things.
I reported the problem to the RealBasic people and thought nothing more of it until I fired up Adobe's InDesign and not being used to working with picas, changed the units of measurement to inches. The default letter paper size was suddenly 8.5000500050005 inches instead of the more usual 8.5! This was not a big problem, but it appears that all of InDesign's page math is running into some kind of rounding errors.
The floating point format is almost certainly IEEE, and I cannot imagine Rosetta doing anything other than using native hardware Intel floating point. On the other hand, there is a subtle difference in behavior.
I am posting this here as a follow up, but I am also going to post this as a proper question in the forum. If you have to delete one or the other of these duplicate posts, please zap the reply, not the question.

Similar Messages

  • Floating point format conversions

    Hi All,
    I have a binary file that has 8 byte floats in it written in VAX D floating point format. It also has 4 byte integers in it. I have to read this file on a Sun Sparc. To get the correct value of the integers I just swap the bytes around and write out the int value, so bytes 0123 get rearranged to be 3210 and then I use that as my int. I tried that with the doubles, reorder bytes 01234567 to 76543210 and then write out the double value but I don't get the value that was stored.
    I read 8 bytes from the file, I'm supposed to get 512.0 but I get garbage.
    The hex dump of the file shows: 0045 0000 0000 0000
    I can't come up with a way to turn that into 512.0
    Another one is 360448.0 with hex dump: b049 0000 0000 0000
    Can anyone show me how to manipulate these bits/bytes to get the correct values?
    Thanks

    Hi Legosa,
    Thanks for looking for a solution for me. The linkhttp://nicmos2.as.arizona.edu/thompson/kfocas/vax2sun.c
    has a C implementation of exactly what I need and has saved me a lot of time and work. Translation to Java will have to use bit shifting I think, the C unions make for a nice implementation.
    I also have to read PC and Cray generated files on my Sun.
    I have found that, like the Vax, Intel x86 including pentium are all little endian and use IEEE so I'm guessing that I just have to do the byte swapping to translate from PC to Sun.
    Crays are Big endian so I don't need byte swapping but I do need to do some manipulation of the exponent and the mantissa.
    Do you know where I might find code that others have done for PC to Sun and Cray to Sun conversions of integers, floats and doubles?
    BTW, for those who may read this later, the solution in vax2sun.c isn't quite right, the author forgot to use the least significant 32 bits and lost 3 bits in the middle but it is very close. To make it closer you have to change the vax2sun.c code a little.
    Replace mantissa and lomant with
    In union ieeebuf
    int mantissa1:20
    int mantissa2:3
    int mantissa3:29
    In union vaxbuf
    int mantissa1:20
    int mantissa2:3
    int mantissa3:29
    int lost_bits:3
    In the code replace d.mantissa = v.mantissa/8 with:
    d.mantissa1 = v.mantissa1
    d.mantissa2 = v.mantissa2
    d.mantissa3 = v.mantissa3
    My few tests showed this gave very good results. The lost_bits are lost because ieee needs 3 more bits for its exponent so it doesn't have room for all of the vax mantissa bits. A little bigger range means a little less precision.

  • Export to .exr / .hdr / floating point format from ACR?

    Hi!
    Context is that I'm doing HDRI images for rendering so dynamic range is the most important aspect.
    I searched hard but didn't found a way to export from ACR into a floating point format which is very very very annoying because if you export as 16bit tiff it will obviously clip whatever values you have in your raw file. I can load the raw / dng files directly into Photomatix / Oloneo but then I'm losing any kind of Camera Profile / Distortion profile embedded with them.
    Oh and I don't want to use Photoshop to Merge the HDRI files because I want to have control over the deghosting and various other alignement related stuff. I'm really searching for a .dng / .raw to .exr conversion.
    Any ideas?
    KS

    I would benefit from first class raw demosaicing, noise reduction, undistortion, optional color profiling, etc... before sending that to merging in whatever software that is not the specialty to do what ACR does perfectly
    Getting linear data out would be the step after all the ones I described and I wouldn't change any exposure, recovery, black level, tone curve, etc ... related options so that the HDRI merge is predictable. That's where the problem resides.
    Lets say you have a photo with a bright sky, you load it in ACR, with everything to zero. Your sky is white and burnt ( But you actually have data from the raw file because you have checked it by changing the exposure compensation to -5 ) If you export the image as is without the exposure compensation, the sky data is clipped once casted to integer.
    If you export it with the exposure compensation, the HDRI merge will be very very bad because the software will have an image with the data where the exposure has been shifted but still exhibit the exif data from the original file.
    Of course you can merge with the tiff without the compensation and rely on a faster exposure to fill the missing data, it works but when you hit your latest fast exposure and you see that you would be able to pump even more dynamic range from it but that ACR clipped the data it's very frustrating.
    I now hope it's crystal clear and why I would like to get a linear exr output I can also upload a raw file somewhere for people having trouble understanding the issue.
    In the best case scenario Adobe will provide a solution, but if it happens it will not be before a while, in the worst case there won't be any solutions at all. With that in mind I wrote a Python script that generates for me the tail exposures for my bracketing sequences and modify accordingly the exif data.
    My workflow is the following for now:
    - Dump raw images from camera.
    - Apply neutral preset, noise reduction on all the raw files.
    - Praise Adobe for ACR.
    - Launch the Python script that:
         - Generates a subfolder where all the raw and xmp files are copied.
         - Images are renamed reordered by their exposure time.
         - The tail exposure is duplicated 3 times.
         - The xmp files are updated with exposure compensation ( -1, -3, -5 ). Now I get the dynamic range.
         - The raw files exif data is altered to reflect the exposure compensation.
    - Load the new raw files from the subfolder and convert them to tif.
    - Rant against Adobe
    - Merge to HDRI with my proper dynamic range.
    KS

  • IEEE Floating point format converstion to ForteDouble

    Question:
    Given that I have 4 bytes of binary data which represents a number in
    IEEE floating point format,
    and I wish to convert it to a Forte DoubleData, will the following code
    give me the correct answer
    in Value?
    (Assume that file is correctly set up, etc...)
    Value : DoubleData = new;
    FPoint : point to float;
    F : float;
    LineText : BinaryData = new;
    File.ReadBinary(LineText,4);
    Fpoint = (pointer to Float)(LineText.Value);
    F = *Fpoint;
    Value.SetValue(F);
    Thanks
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Mark,
    you might try testing whether forte floats are IEEE in the following
    way using the following:
    pflt : pointer to float = (pointer to float) (res.value);
    flt = *pFlt;
    however, I believe you will have to wrapper a C function to do this.
    The C function takes a void * first argument and has a float
    void ConvIEEE(void * buffer, float * return)
    return = (float) (buffer);
    or
    void ConvIEEE(void buffer, float return)
    ieeefloat ie;
    ie = (ieeefloat) (*buffer);
    *return = IEEELibraryConvertToFloat(ie);
    depending upon whether C floats are IEEE or not on your
    platform/compiler. I think you'll have to investigate this yourself,
    or try the first approach and see if it works.
    Good luck!
    assuming, of course, that your C compiler's float is also IEEE format.
    Your forte wrapper would look like
    class floatWrapper inherits from framework.object
    has public method ConvIEEE(input buffer : pointer,
    output return : float)
    end class;
    with your binarydata you would
    res : binarydata = (get from somewhere)
    flt : float;
    fw : FloatWrapper = new;
    fw.ConvIEEE(res.value,flt);
    Mark Sundsten wrote:
    >
    Question:
    Given that I have 4 bytes of binary data which represents a number in
    IEEE floating point format,
    and I wish to convert it to a Forte DoubleData, will the following code
    give me the correct answer
    in Value?
    (Assume that file is correctly set up, etc...)
    Value : DoubleData = new;
    FPoint : point to float;
    F : float;
    LineText : BinaryData = new;
    File.ReadBinary(LineText,4);
    Fpoint = (pointer to Float)(LineText.Value);
    F = *Fpoint;
    Value.SetValue(F);
    Thanks
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>--
    John Jamison [email protected]
    Vice President and Chief Technology Officer
    Sage IT Partners, Inc.
    Voice: 415 392-7243 x 306
    Fax: 415 391-3899
    Internet Enabled Business Change
    http://www.sageit.com
    -----------------------------------------------------

  • Can PPC and Intel OS's be on the same hard drive?

    I do a lot of work on Apple computers for clients.
    I have made it a habit to bring firewire hard drives with OS X installed to my work locations so I can boot peoples' computers from my own, clean OS for numerous troubleshooting purposes.
    I was hoping to take a big hard drive I have, partition it into 4 parts, and install 10.4 Intel, 10.4 PPC, 10.5 Intel, and 10.5 PPC.
    But after I installed the PPC 10.4, I went to my macbook pro and tried to install 10.5 Intel.....and it wouldn't let me!
    So now I am learning about the Apple Partition Map format for a drive versus the GUID format and that basically one is for PPC and the other for Intel.
    But I would like to know if there is any way to format a drive in such a way that I can indeed install PPC and Intel version of an OS onto one physical drive in separate partitions???
    anyone?

    It's not intuitive but it's possible. You must set up your external drive using the APT partition map. Install the PPC version of OS X on one partition. Now here's the trick: You must install an Intel version of Leopard on a drive that has been partitioned using GPT. Then clone that installed version to another partition the external drive that now has the PPC version of Leopard. You now have a PPC version of Leopard on one partition and in Intel version on the other partition. You will find you can boot an Intel Mac from that partition even though the drive is partitioned APT.
    The problem is that Leopard will not allow itself to be installed on an APT partitioned drive. But an Intel version of Leopard will work just fine from an APT partitioned drive.

  • Difference in sound between Logic on PPC and Intel (64 Bit)

    hi,
    I'm using PPC for Logic Pro. Is there any difference in sound between using logic pro on PPC and running it on Intel Macs. I'm not good in tecnical things, but someone told me, Logic would sound better on Intel based Macs, because the system is 64 bit instead of 32 bit on PPC. Is that true? Any experiences?
    Thanx,
    grooveX

    There are no differences!
    the "sound quality" is stryctly relted with the Audio equipment.
    (the new Intel Xeon processors are faster than PPC... in 2008... obviously... but in 2003/4/5 PPC G5 was much faster than same year 2003 Intel Xeon release
    If you work with DAE TDM HD accell in PPC or on Intel the sound will be the same...
    obviosly if some update shoot down the compatibilty with PPC side you will cannot use the future upgrades...
    if you use a Motu 828 Mk3 the sound will be great... and same as ppc or Intel or Windows and Linux
    (but Logic works on Mac... PPC and Intel... is the same... logic is the master of the sound).
    Anyway... I think the analog recording studio in the 1970 1990 gives you a super great sound... in some cases the analog recording studio sonds much better that digital studios..
    I'm talking about a simple example.. the audio frequency are from 20 to 20.000 HZ... the music quality... (artistically) is not related with the quality of the machine that you use for make it....
    I suggest you not follow the mode ... and run to buy the last model .. most often are money thrown to the wind.
    if you buy a good new interface.... you are in the rigth way...
    but the very important thing is:
    MAKE YOUR MUSIC AND DON'T MATTER ABOUT these unnecessary competitions ... is only useful to those who sells computer!
    I know people that doing good music with old G4 ...
    ...music with highest quality ...
    is not the machine that makes the music .... Only MEN can obtain a piece of art ... even using dirt!
    G

  • External hard drive for both a PPC and Intel Mac?

    I have 2 LaCie Hard Drives (500GB & 750GB) that I'd like to use for backing up my 2 laptops and for storing photo and music files.
    When I got the MacBook Pro, I partitioned the 500GB drive into 3 volumes and used SuperDuper! to make "bootable" copies of the MBP on one volume, theiBook on one volume, and put photo files on the third. I don't know/can't remember how I dealt with the directions below from Disk Utility and I fear I may have done the impossible or at least done the wrong thing.
    "If you will use a volume as a Mac OS X startup disk, click Options and choose the appropriate partition scheme. To use a volume to start up an Intel-based Mac, choose the GUID partition scheme. To use a volume to start up a PowerPC-based Mac, choose the Apple partition scheme."
    As I ask these questions, I find myself getting tongue-tied so please bear with me and read on...
    #1 - Is it *even possible* to do what I want and have the bootable copies of both of these laptops on the same HD since one is PPC and the other Intel? If the answer if yes, it's OK then the rest of this is moot.
    #2 - I can easily delete one or the other laptop backup from the 500 LaCie and put it on the virgin 750 and partiton it - problem is, is there a way to know how I partitioned the 500 HD so I won't have to redo it -I don't want to have to recopy the thousands of photo files already on the HD. If I knew how it was partitioned - Intel or PPC - I could just delete the appropriate laptop and move it to the other LaCie, assuming I have to.
    #3 - And, is it possible to use a drive that has been partitioned for PPC or Intel with the other type computer - will I be able to access the jpg photo files from both the MBP and my G4 both of which are Tiger no matter which way the HD is partitioned? Now I as able to do this, but as I said, I don't remember which way I partitioned the HD - all I remember is that I did choose to include OS 9 drivers since I still use Classic and OS 9 on the G4. ( I have yet another LaCie that I use exclusively to back up my G4 and it is not part of this issue)
    Mrs H

    So "To use a volume to start up a PowerPC-based Mac, choose the Apple partition scheme." really means it will work for my Intel MBP too?
    Yes.
    Is there a way to tell if that is what I already choose?
    Select the existing drive in the Disk Utility and find the Partition Map Scheme text at the bottom of the window.
    (34529)

  • OS X 10.4.x on PPC and Intel having problems with Card Readers

    Hello,
    I am in charge of a school district running about 75 client macs, all PPC G5 and Intel mixed. I have been having reports that the Lexar card readers for the digital photography lab sometimes do not auto-mount the media that is inserted into them. Apple System Profiler detects the card reader, but when the card is stuck into the reader it does not appear in finder at all to retrieve the files.
    Upon testing, a reboot usually alleviates the problem, but the teachers feel that the interuption in class and productivity time for a reboot is unacceptable.
    I have the user accounts managed through Workgroup Manager on my Xserve, and I have it set so that they have access to auto-mount media (unless I'm missing a setting somewhere. But i'd think if the setting was off, the reboot wouldn't matter and it wouldn't fix the issue).
    At anyrate, my question is has anyone else expierenced problems with card readers and auto-mounting the media in OS X? How about in a multi-user environment. Does anyone have any suggestions? All are welcome.
    Thanks so much for your time.

    Since the latest update Mac OS X 10.4.9, my USB card readers have stopped working. The media is recocognized, but the transfer rate is so slow I could manually write the binary.
    There were no issues prior to this update, and card readers work on machines NOT updated.

  • GUID or APM for PPC and Intel Macs

    Apple Article 306932 states
    Click the Options button.
    Select a new partition scheme:
    Use "Apple Partition Map" partition scheme if the disk will be used with Time Machine and a PowerPC-based Mac.
    Use "GUID" partition scheme if the disk will be used with Time Machine and a Intel-based Mac.
    So, I have a PB G4 (PPC) and a Mac Book Pro (Intel), both of which I want to use with TM to one external drive.
    So, which partition scheme should I use?

    I suggest that you take a look at the following links as they may provide you with an answer :
    http://www.macosxhints.com/article.php?story=2006061610374449&query=apm%2Bguid
    http://www.macosxhints.com/article.php?story=20060322054212363
    http://rentzsch.com/tidbits/intelbasedMacBootIncompatibility

  • Partition scheme for PPC and Intel

    I have a G4 mini and an Intel Macbook and one USB harddrive to back them up with time machine. I think I'll connect the drive to the mini and share the drive so I can back up the Macbook.
    Anyway, I was reading:
    http://docs.info.apple.com/article.html?artnum=306932
    and it says to choose the "Apple Partition Map" scheme for use with PPC and "GUID" for use with Intel. Anyway, I was wondering what I should choose when I need to use it with both processor types.
    Thanks for any advice!

    Oops, it seems that a similar message appeared while I was posting this one, so I think I might as well just follow the discussion on that thread, sorry for the duplicate.

  • Erasing Time Machine hard drive after formatting for both PPC and Intel

    Ok, I made a mistake. First I formatted a Western Digital 500 gig hard drive for both my wife's PPC G4 laptop and my own Intel MBP laptop, so we could both use Leopard's Time Machine for backing up to the same drive. That wasn't my mistake though, it's been working fine. I formatted my partition using the GUID option and hers using the Apple Partition Map option (I think that's what they are called, I'm going from memory).
    Here's my mistake: I needed some extra space to store some files and read that I could Re-Partition the drive without erasing anything using Disk Utility. Sounded great. I first tried to partition my wife's partition, since she had more extra space, but then I realized that was a bad idea since I had formatted her partition with using the Apple Partition Map, so I stopped and then tried to Re-Partition my side. It worked for about an hour: my Time Machine backup drive appeared, my new partition appeared, but then... her partition disappeared! Usually whenever one of us plugs in the hard drive using the firewire cable, both partitions appear, Time Machine Goes to work, and that's that. When we need to disconnect from the drive we have to eject both drives, but no big deal. Now her drive isn't appearing.
    So... I tried to repair it, no good. Tried to erase both her partition and mine (to just start over): no good. I can't do anything to either of these partitions now, from either computer. Tried everything I could think of in Disk Utility, from both computers. Won't erase, won't re-partition. Not a hardware issue: it all started when I did this stupid Re-Partition. Help!!!!
    I want to erase the drive and start over. Can anyone advise??

    Jasonmo,
    First, let's talk about the various partition schemes. A partition scheme applies to the entire drive. Specifically, these are different maps written to the drive, within which volumes are created. As such, this is an either/or thing; your drive is partitioned using either the GUID Scheme, or the Apple Scheme, not both.
    "Live" partitioning or re-sizing of existing volumes is supported only under the GUID Partition Scheme. If the drive wasn't using this scheme, you would not be able to re-size as you were attempting to do. Even re-sizing under the GUID scheme requires that the drive's maps and directory structures be in very good shape, if it is to work without hitch.
    Are you absolutely certain that there isn't some physical problem with the drive, or with its interface (cables and such)? If it is operating normally, you should be able to re-partition it without problems. In DIsk Utility, select the drive (not a named volume that will appear indented underneath), then click the "Partition" tab. If you wish to be able to re-size volumes later, you must choose the GUID scheme from the "Options..." dialogue sheet. Set appropriate sizes for the volumes, then click "Apply." Doing so will destroy all current volumes and data on the drive.
    Scott

  • Float point format function --- "Beginner"

    Hii every body
    1-I want to format any float number to be with only two decimal digits
    examble :
    95.3213 converted to be 95.32
    is there any function that can do this ???
    2- I want to remove any spaces from any given string
    examble:
    mystring = "Hi my friend " coverted to be mystring = "Himyfriend"
    thank you ...

    1 Check out the API for java.text.DecimalFormat
    double d = 95.3213;
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(2);
    System.out.println(nf.format(d);2 If you have java1.4 you can use the replaceAll method in string:
    String myString  = "Hi my friend ";
    myString = myString.replaceAll("\\s", "");The regular expression "\s" matches all whitespace - spaces, tabs etc etc

  • Floating point format in report

    I am using TestStand 3.1 and LabVIEW 7.1. I set the default report format for HTML report to _whatever_, %#5.13f, append trailing zeros etc, and this format is present for report entries such as limits. It is not present for the actual measured value, and this seems subject to some display format rounding. For instance, my limit test will be GELE and the lower limit will be 3.0000000000000. The measurement will be 2.956785434 and the test will fail, but in the report the measurement is formatted as 3.0. What has gone wrong?

    Hi Odd_Modem,
    Sorry for the crazy email. I accidentally replied when I was not ready.  
    Anyway, the third option was the Tree View. Once inside the tree, browse to Main >> Numeric Limit Test >> Result >> Numeric.  Right-click on the numeric field (in the right window) and select properties. Then select Numeric Format and change the significant digits.  This should fix your issue since this property is the highest precedence. The order of precedence is (Numeric in Tree View -> Limits -> Report options).
    Hope this helps!
    Best Regards,
    Jonathan N.
    National Instruments

  • Mixed up PPC and intel

    Hi,
    I am getting this error.
    cputype (18, architecture ppc) does not match cputype (7) for specified -arch
    flag: i386 (file not loaded),
    And as found out it means -
    I have some stuff [perhaps mpich] comiled for PPC CPU - but now you have an Intel i386 CPU. You can't mix these two.
    Is there a way to undo it ? How can I remove the files that got compiled PPC CPU.
    Thanks.
    Regards,
    Ila

    Have tried doing a "Clean" or "Clean All Targets" from the Build menu?

  • Internet Sharing for PPC and Intel based Macs

    I have OSX 10.4 Server running with NAT and DHCP enabled. The internet is accessed through a wired connection, and 2 Powerbooks(PPC based) and an Intel iMac and MacBook connected to the server via Airport. The wireless signal is WEP protected, and the Intel based Macs can connect to the wireless network, recieve a good IP address and access the internet. These two connected computers can be seen on the Server Admin DHCP Clients tab.
    My problem is with the PPC based Mac, the 2 PowerBooks. Those computers can connect to the wirless network, but they get an invalid IP address. Not only is the IP invalid, so is the Subnet Mask.
    All computers are running 10.4.7, and all installed from the Combo Updater.
    Any suggestions?

    We're having the same problem here!
    Rarely we manage to get the right IP address assigned to one PPC machine by playing with various network settings but we didn't found a reliable way to get the PPC machines always working.
    This is really strange... any suggestion is appreciated.

Maybe you are looking for