DataInput, DataOutput , unsigned, and little endian

Why are readUnsignedInt(), readUnsignedLong(), etc missing from DataInput?
Also, DataOutput doesn't even have writeUnsignedShort() or writeUnsignedByte()
Another thing, Little Endian input/output streams are completely missing.
I've found about 900 implementations of this missing functionality floating around the net. So the question is, why isn't it part of the standard api?
--Stephen                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

I realize this. There are hundreds of implementations floating around the net that implement it. Obviously a lot of people want it. Why is it not part of standard java?
--Stephen
Java does not support unsigned byte/short/int/long.
If you need these you need to read the right width and
convert to the int or long or BigDecimal to process
the number you need.

Similar Messages

  • Any need for conversation from big endian and little endian?

    Hi,
    I am planning to migrate an Oracle 9i Database on AIX 5.3 to Oracle 11g R2 Windows 2008, and have planned to use transportable tablespace. But prior to that task is the conversation required from big endian and little endian using RMAN?
    Appreciate any suggestions, comments and hints
    Thanks

    Hi,
    Check V$TRANSPORTABLE_PLATFORM, it shows the ending for each supported platform. Given the results on my 11g, I suspect that you'll have to convert the tablespaces...
    SYSTEM@oracle11 SQL>select *
      2   from V$TRANSPORTABLE_PLATFORM
      3  ;
    PLATFORM_ID PLATFORM_NAME                                                                                         ENDIAN_FORMAT
              7 Microsoft Windows IA (32-bit)                                                                         Little
              6 AIX-Based Systems (64-bit)                                                                            Big
              8 Microsoft Windows IA (64-bit)                                                                         Little
             12 Microsoft Windows x86 64-bit                                                                          LittleHtH
    Johan

  • Big Endian and Little Endian formats.

    How can I read numbers from file in both big and little endian formats?

    Not without reading them a byte at a time and doing
    bit-shifting arithmetic yourself.I was hoping I will not get that kind of answer :) Well, if that's the only way,
    can you tell me what kind of format is used in Java? Big or Little endian?

  • TCP Programming / Why do not need to worry about Big and little Endian?

    Please help, I do not understand this concept please explain.
    The architecture of a CPU is either little-endian or big-endian; some modern CPU's allow a choice via software.
    The TCP/IP protocol standard specifies that all the bytes that make up an item must be sent in "network order", which happends to be big-endian. Intel Pentium CPU's are little-endian.
    This implies that on an Intel machine the TCP software will have to chop an int into bytes and then reverse the bytes before transmitting them.
    Why does the JAVA TCP software does not need to perform the reversal?
    Thanks,
    Alex

    But why would I need to use the DataOutputStream,You don't have to.
    But that's what the Java API provides for sending java primitives over a stream. You wouldn't have to use that. You could chop the int into bytes yourself, and send the bytes, and your Java code still wouldn't have to worry about the endiannes of it, because the VMs handle that.
    DataOutputStream just does the chopping and reassembling for you, so it's easier than doing it yoursefl.

  • Why do not need to worry about Big and little Endian in Java

    Please help, I do not understand this concept please explain.
    The architecture of a CPU is either little-endian or big-endian; some modern CPU's allow a choice via software.
    The TCP/IP protocol standard specifies that all the bytes that make up an item must be sent in "network order", which happends to be big-endian. Intel Pentium CPU's are little-endian.
    This implies that on an Intel machine the TCP software will have to chop an int into bytes and then reverse the bytes before transmitting them.
    Why does the JAVA TCP software does not need to perform the reversal?
    Thanks,
    Alex

    Java doesn't give you direct access to the individual bytes of a larger data item such as an integer. For this reason you don't have the usual endian problems that occur in C. The actual handling of this is in the DataOutputStream and DataInputStream where the integer is coverted to and from bytes using arithmetic, not by fiddling with the internal structure.
    Note that regardless of the machine architecture the operation value%256 will return the low order 8 bits. It's less efficient than assigning an int* to a char*, but it's not fraught with the endian problems or any of the other hardware baggage.

  • How do I swap 64-bit and 32-bit floats from little-endian to big-ending

    I am trying to read a file that could contain a list of 64-bit floats or 32-bit floats that were written on a PC so they are little-endian.
    I need to convert the float values to big-endian so that I can process the values. I know that straight swapping each byte with the adjacent byte doesn't work (especially since their floating point values). I've tried swapping them end for end (i.e., byte 15 from the file becomes byte 0 in my array) and that didn't work either.
    I know that if I were to read the little-endian float into the big-endian float type (float or double) that the format is pretty much lost (from little I understand about how floating point values are stored in memory).
    So, what I need is a way to read in a series of little-endian floating point values (64-bit and 32-bit) into a big-endian array of floating point values.
    Anyone have any ideas on how to do this? Any help would be much appreciated.

    A 64-bit double is represented by the sign bit, an 11-bit (biased) exponent
    followed by a 52-bit mantissa. Both x86 and SPARC use the exact same
    representation for 64-bit double. The only difference is the endianness
    when stored to memory, as you observed.
    A 32-bit float is represented by the sign bit, an 8-bit (biased) exponent
    followed by a 23-bit mantissa. Again, both x86 and SPARC use the exact
    same representation for 32-bit float modulo endianness.
    As you can see, a 64-bit double is not merely a pair of 32-bit float.
    You need to know exactly how the floating-point data was written:
    if a 32-bit float was written, you must endian-swap it as a 32-bit float;
    if a 64-bit double was written, you must endian-swap it as a 64-bit double.

  • What does Little Endian and Floating Point actually do?

    Exporting audio to video using Linear PCM format brings along two mysterios options called "Little Endian" and "Floating Point". I did my research but all I could dig out was that the first one, Little Endian, has to do with addressing subcomponents of a file etc.
    Does anyone know what these two actually mean in terms of exporting audio and why do I only see them in logic and not in Protools for example?
    Thanks...

    Big Endian is most significant byte (bit) first, Little Endian is most significant byte (bit) last. When we write down a number, we use big endian: one million threehundred and twentyfivethousand ninehundred and fiftyfour we'd write as 1 325 954. in little endian notation that would be 459 523 1.
    I don't know why they show up when exporting audio to video, maybe it is to adaprt the audio to some other (older?) formats?

  • Big endian, little endian, and converting to another datatype.

    Hi all,
    I'm working on a sound visualization program. I'm putting the sound into byte arrays, and I then need to convert those bytes into ints to draw onto the screen. This is easy if the soulds are 8-bit, because you don't have the endian issue. How do I take a byte[] and pull ints from it that represent the waveform that the bytes were pulled from? Is it something like this (where soundBytes is the byte[] pulled from a sound file):
    int sampleFirstPart = (int)soundBytes[0];
    int sampleSecondPart = (int)soundBytes[1];
    int putTogether = sampleFirstPart + sampleSecondPart * 128;
    That's just a wild guess, and I'm not really sure what order these things should go in. How do you do it if it's big-endian? What about if it's little-endian? Is there a preference of one over the other? Does the fact that I'm working with wav files make a difference.
    I'm just full of questions, but any ammount of help you can give is very very much appreciated.
    thanks,
    Matt

    int value = soundBytes[x] + (soundBytes[x+1] << 8); // LE
    or
    int value = (soundBytes[x] << 8) + soundBytes[x+1]; // BE
    I think the LE and BE labels are right, but the calculation part is correct for one or the other.
    However, you need to know the format of the file to know if it's one or the other. You can't really tell from the bytes whether it's one or the other. There should, presumably, be some way to know from the audio format header. Either there'd be a flag to incidate which, or it would be assumed one way or the other because it's of format X. I think that wav files would be LE, but don't quote me on that.

  • Swapping little endian short to big endian short

    I am trying to read a unsigned short value that a C program generates in my Java MIDlet. I am reading the data using a ByteArrayInputStream in conjunction with a DataInputStream. I tried calling readShort but it was returning bogus values. Here's the problem:
    The short I am trying to read in is 0xb500 (it was generated on a little endian machine) the value should be 181. I realized my mistake using readShort (it was signing the value) and so I called readUnsignedShort instead. Now the value of the int after the call to readUnsignedShort is 0xb500 (46336). I need to swap this value back to 0x00b5 (181) on the Java side. I have used the following function, but it returns 0xb50000 and i'm not exactly sure why.
    The swap function is like so:
    public static int swapInt(int i)
         return ((i << 24)
    | ((i & 0x0000ff00) << 8)
    | ((i & 0x00ff0000) >>> 8)
    | (i >>> 24));
    I do not have any idea what >>> is in Java. I found this function on google groups. If anyone could help me find a solution to my problem it would be much appreciated.

    An int is a signed 4 byte value (as I am sure you know)
    You are using an int to represent an unsigned 2 byte value.
    Now you want to swap the 2 bytes of your unsigned 2 byte value.
    This means that you only want to swap the two least significant bytes of your int.
    Oh, by the way, USE CODE TAGS TO FORMAT CODE!!!
    [code]
    public static int swapUnsignedShort(int i) {
        return ((i & 0x00FF) << 8) | ((i & 0xFF00) >> 8);
    }[[i]code]

  • How do I install Adobe Flash Player on Ubuntu 32bit ARMv7 Little Endian machine?

    How do I install Adobe Flash Player on Ubuntu (12.04) 32bit ARMv7 Little Endian machine? The .tar.gz and .deb files contains shared libraries for i386 target.

    Hello,  
    There is a procedure of Manual Installation of Adobe Flash Player on Ubuntu, follow these steps :
    Open http://get.adobe.com/flashplayer/otherversions/
    Choose Linux 32-bit on Step 1
    Choose Flash Player 11.2 (tar.gz) on Step 2, download the file
    Once download is complete, right click on the flie (tar.gz) and click on "Extract here"
    Launch Terminal (Keyboard Shortcut : Ctrl+Alt+T)
    Go to that location where you extracted the file
    Run this command : sudo mv libflashplayer.so \/usr/lib/firefox-addons/plugins
    Launch Mozilla Firefox and check do you have Adobe Flash Player
       Thanks,
    Vikram

  • How to extract a double from a little endian stream?

    I want to support Java 1.3.1, which means that I cannot use class ByteBuffer.
    I would need ByteBuffer with the methods order and getDouble.
    I read the socket in little endian format (thus I cannot use the getDouble method of the class DataInputStream). Is there any solution in Java 1.3.1 to extract a double from 8 bytes?
    In other words, if I want to keep my code compatiple with Java 1.3.1, do I have to change the order of the bytes manually and then also extract the double value manually (extracting the sign-bit, the exponent and significant to calculate the double value is possible but quite stupid if there is another way...)
    It would also help to have the release notes for Java 1.4.2. ( the link on the SUN pages points to nowhere). I am especially interested in the history of the development of ByteBuffer. Did the functionality of order (LITTLE_ENDIAN / BIG_ENDIAN) exist in any other way in Java 1.3.1?
    Ps. I put another case to this Forum earlier today, and even added it to my watch list, and even got an answer BUT after relogin there was not even a sign of that case... I sent feedback to SUN but I'm sorry for not being able to get back to the person who answered my case.

    Thank you for your help, meloro77!
    I modified your masks and shifts and then finally created the proper method for the double values.
    There was one more trick needed: each byte MUST be converted into a long value before running the shift! The byte and the result is otherwise treated as int (32 bytes and any bytes higher than this would be discarded.
    For your and everybody else's fun and joy, I include here the code which I used:
    byte []   doubleData = new byte[8];
                 reading the bytes
          double myDouble = 0.0;
          // Create a long value of the bytes
          long doublebits;
          short MASK_TO_BYTE = 0xFF;
          doublebits = ((long)doubleData[7] & MASK_TO_BYTE)
                      | ((long)(doubleData[6] & MASK_TO_BYTE) << 8)
                      | ((long)(doubleData[5] & MASK_TO_BYTE) << 16)
                      | ((long)(doubleData[4] & MASK_TO_BYTE) << 24)
                      | ((long)(doubleData[3] & MASK_TO_BYTE) << 32)
                      | ((long)(doubleData[2] & MASK_TO_BYTE) << 40)
                      | ((long)(doubleData[1] & MASK_TO_BYTE) << 48)
                      | ((long)(doubleData[0] & MASK_TO_BYTE) << 56);
           * Let method Double.longBitsToDouble convert the value to a double
          myDouble = Double.longBitsToDouble(doublebits);

  • What is Little Endian / Big Endian in Sound settings for Apple Intermediate

    Hi.
    In Final Cut Express, I am trying to splice together multiple video clips, combining footage from:
    1) HDV camcorder imported into iMovie 08 as 960 x 540 (the "lower resolution" option from iMovie '08 import), 16-bit @ 48 KHz (Big Endian), 25 FPS
    2) AVI files (DiVX 512 x 384, MP3 at 44.1 KHz, 23.98 FPS)
    3) Canon Camera "movie" files (Apple OpenDML JPEG 640 x 480, 16-bit Little Endian, Mono @ 44.1 KHz, 30 FPS)
    Questions
    1) What is this little endian / big endian thing?
    2) What is the best codec for me to edit in? My targets are NTSC DVD and also a HD version served via iPod connected to HDTV.
    I am not sure what codec to convert everything to, so that I can edit without having to RENDER every time I do something. I tried to export using QuickTime Pro to convert to Apple Intermediate Codec but am not sure about the option for "Little Endian" (I am using an Intel Mac; I assume I do NOT use little endian? Can someone help clarify?)
    Many thanks!!!

    1. They're compression formats. Different codec use different compression schemes.
    2. You should convert your material to QuickTime using the appropriate DV codec and frame rate.
    None of your material is HD. Some of it is low resolution, lower than even DV. There is no good way to make this material HD.

  • Converting 'little endian bytes' to short

    i need to convert to bytes in little endian format (low order byte first) into a short. i wrote an algorithm that i thought would solve this problem. it seems to work most of the time, however occassionally it does produce the wrong value. i was hoping someone out there could help me solve this problem
    public static short ByteToShort(byte one, byte two)
    // little endian format
    // remember LO then HO bytes
    short result = 0;
    result = (short) ((two << 8) + one);
    return result;
    }

    byte one and two are converted to int in the operation (before reconverted to short in the assignment).
    We must be extra careful here with possible signed bytes.
    public static short ByteToShort(byte one, byte two)
      // little endian format
      // remember LO then HO bytes
      short result = 0;
      result = (short) (((two << 8) & 0xFF00) | (one & 0x00FF));
      return result;

  • One little endian - Windows to AIX possible?

    Hello all,
    I'm trying to find out if it is possible to use Oracle 11g RMAN to copy/convert an existing database on a Windows 64bit platform to AIX 6.1 platform.
    Per the10g document below, it seems the restriction is based on the endian order (32 bit, 64 bit, etc.).
    http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/dbxptrn.htm#CHDCFFDI
    The principal restriction on cross-platform transportable database
    is that the source and destination platform must share the same
    endian format.
    For example, while you can transport a database from Microsoft
    Windows to Linux for x86 (both little-endian), or from HP-UX to AIX
    (both big-endian), you cannot transport a whole database from
    HP_UX to Linux for x86 using this feature.So: is it true if the Windows database is on a 32 bit platform, then RMAN cannot copy/convert the database from the windows platform to the AIX platform
    And by contrast, is it true that it would be possible for RMAN to copy/convert the database from Windows to AIX if the Windows platform were 64 bit?
    Also, it seems there are still files that would have to be recreated manually (redo logs, controlfiles, spfile, etc.).

    MOS Doc 733205.1 (Migration of Oracle Database Instances Across OS Platforms) may help
    Srini

  • How to read data which is written in little endian using labview

    dear all
    My program in c++ creats a binary file with data as
    struct varaiable
    int a;
    double b;
    doublec;
    float d[30];
    floate[50];
    char time_date[30];
    30 such data type is stored in one .b file.
    when i am reading the file back using labview the data is not the same as stored.
    i think that my c++ program stores data in little endian format while labview is retrieving it in  big endian format.
    i Checked and found that when i am storing a=2 then while retrieving back in lab i displays it as HEX of 02 00 00 00.
    Same is the problem with double and float.so can somebody tell me how i can change labview to read in little endian format.
    I am using labview7.1 
    Abhimaniu

    Yes you are correct. Labview and C uses different endian format. Do not worry you have the toolbox in labview. The most important is the typecast function. With this you can convert anything into everything. And as long as you keep the number of bytes and the internal order intact you will always be able to convert things back. I have made an example for you regarding this topic. It is in LV7.1. I have kept this version since the new butt ugly graph cursor introduced in LV8 is a gigantic bug, and should never have seen the light of day.  Well enough of my frustration. In the data manipulation palette you will find the type cast and tools for byte/integer swapping and byte/integer splitting and merging.  If have done a similar thing before. But I do not remember exactly how to convert a C double into a labview DBL. But take a look at the number 123.123. In this number all the internal bytes are different so by comparing the C version and the labview version byte by byte you will be able to convert it correct. I your case the C struct is 4+8+8+(8X30)+(8x50)+30=690 bytes long. So this is the number of bytes you read each time. I your case I think it will be more convenient to read it as an array of 345 I16(words) but this is up to you.
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)
    Attachments:
    sample.vi ‏59 KB

Maybe you are looking for

  • About Me link is not visible in Welcome Menu if placed on custom location in Custom Master Page

    Experts, I am facing a problem in my -ongoing SP 2013 project's branding. The problem is with Welcome Menu. I need to put the welcome menu at a custom place rather than in ribbon area. for this I added welcome menu snippet inside my Master Page HTML

  • PAN no mandatory

    Hi expert while creating a vendor master, i want PAN no field to mandatory, i have check in vendor screen layout , but i didnt got the field for PAN no, Please help me. regard nabil

  • Aperture 2 or 3: delete unused masters?

    I am upgrading my 2 library to import into version 3. Before doing that I want to clean up my old library by deleting unused masters from the library.In other words: I only want to retain those photos that I have placed into Albums. I can't figure ou

  • Yosemite Server 4 Messages Group Auto Buddy Not Working

    I know I have had issues with the group auto buddy in the past versions of server, and I am setting up a new Yosemite Server 4 from scratch with OD. I have checked the box in a group to make members buddies automatically, and it isn't working. I went

  • Wrv210 How to use vlan feature?

      Hi people. I have 1 WRV210 Wireless Router, this device have the vlan feature, I have read about this feature that u could have separate networks example: 192.168.10.X net-1 10.0.8.x net-2 My ISP use pppoe, is working, but I dont know how to setup