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?
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
ThanksHi,
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 -
Can Lincat find big endian and small endian problem?
Hi, I want to migrate a project from linux to solaris. And I read that lincat can save a lot of time in migration. But when I tried with lincat. I found that what is found is mainly the difference between linux API and solaris API. I use the following
codes:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
int flagVal = 0x01020304;
char cptr = (char )&flagVal;
printf("Val is %d\n", *cptr);
my lincat does not find the big endian and small endian problem. I also wonder whether lincat can find the misaligned problem and "32 bits and 64 bits" problem. Could you please tell me? I didn't find the answer from lincat manual.
Edited by: baiwd on May 6, 2008 6:03 PMHi Ankit,
You may use "Cross Platform Transportable Tablespaces" method if the endian format is different between source and target platforms. Please have a look at Oracle's "Platform Migration Using Transportable Tablespaces" document for more information: http://www.oracle.com/au/products/database/maa-wp-11g-platformmigrationtts-129269.pdf
Please note that "Transportable Database" is a different feature and can only be used to migrate a new database platform that has the same endian format.
BR,
Alper Somuncu -
Hello,
Is JVM big-endian or little-endian? Or is it platform dependent?
How does one check this?
Regards.I also saw over the internet that java is big-endian. But when you run this small piece of code,
class Test {
public static void main(String[] args) {
short x = 10;
byte high = (byte)(x >>> 8);
byte low = (byte)x;/* cast implies & 0xff */
System.out.println( "x=" + x + " high=" + high + " low=" + low );
The output is:
x=10 high=0 low=10
This sample code I have taken from "mindprod.com" site only.
Is storage different from display? Or am I missing something here?
Regards. -
Is IntelCore processor big-endian or little-endian?
Hi,
I need to know if Mac mini's processor is big-endian or little-endian.
Thanx.Little-endian.
Snippit from What is endianness?:
"On the Macintosh platform, PowerPC-based Macintosh computers use big endian addressing, while Intel-based Macs use little-endian addressing." -
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,
AlexBut 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,
AlexJava 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. -
VDI 3.1 Big Endian vs Little Endian: VDI Cluster to Remote mysql server
Hello,
We are implementing a Dual Data center VDI environment and with that, will be using VCS to Cluster a remote Mysql instance. My question, if the VDI Cluster is on x86 (Little Endian), can the remote Mysql DB be on Sparc (Big Endian)?
Thanks,The endian matching is only a requirement for the management and data nodes of a MySQL cluster. If you are going to be using a remote MySQL DB, the VDI servers will be connecting to that remote MySQL DB as a client connection, and there is no requirement for clients to match the endian type.
http://dev.mysql.com/doc/refman/5.1/en/mysql-cluster-limitations-exclusive-to-cluster.html -
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?
--StephenI 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. -
Big RAM and little RAM for Wallstreet
Hi,
I just received my 512MB (2 256MB chips) RAM for my PowerBook G3 Wallstreet. One of the chips is the normal size and the other one is much bigger, but it will still fit in perfectly, it's just alot wider, like double the other chip. My question is: Which chip goes in the bottom slot and which goes in the top?
ThanksWell, I installed the modules and it seems to run great (recognizes all 512MB). If it starts to act weird I'll put the 192MB back in but it does seem to run just fine. And, as I said, the seller guarantee's that the RAM will work in this machine so If It causes my machine to stop running then they're responsible. Here's the actual description from the auction:
This auction is for 512MB KIT MADE OF 2PCS OF 256MB PC100 SO DIMMS. ONE WILL FIT IN THE UPPER SLOT AND ONE WILL FIT IN THE LOWER SLOT OF THE POWERBOOK G3 WALLSTREET/LOMBARD VERSIONS. These modules have been tested in our ISO 9001:2000 Government approved facility. Like all modules we sell, these modules have a LIFETIME WARRANTY and is GUARANTEED to be compatible with your Model. -
Java big/little endian file support
Hi, hope you can help,
Firstly is Java bigendian or little endian or is this non manifest.
I have a binary file that may exist either in big endian or little endian format.
Is there support for reading differing byte orders, if not how do I go about reading either format.
Many thanks in advance,
AaronYes, Java has support for both byte orders.
http://developer.java.sun.com/developer/JDCTechTips/2002/tt0507.html is an issue of JDC Tech Tips that discusses the use of java.nio.channels for this and has example code for writing and reading both orders.
Many thanks.
Sorry but there seems to be no way to award duke points a second time :(
Aaron -
Big endian - Little endian conversion
Hi all, I'm a new user!
I'm working with As400 and java using jtopen.
With this code:
PrintObjectTransformedInputStream is = spoolFile.getTransformedInputStream(printParms);
BufferedInputStream bufIn = new BufferedInputStream(is);
BufferedOutputStream bufOut = new BufferedOutputStream(new FileOutputStream("c:/x.tif"));
int c;
while ((c = bufIn.read()) != -1) {
bufOut.write(c);
bufIn.close();
bufOut.close();I'm getting a tiff stream and then write it to a file. The tiff stream is in Big endian format, but I need a tiff in Little endian format.
How can I convert the stream from Big endian to Little endian?
ThanksTiff is a complex format, containing fields of different lengths, so you aren't likely to succeed just by reversing every pair of bytes in the stream without following the TIF format.
You could look at the JAI (Java Advanced Imaging), which can read and write TIFF files in a variety of modes. -
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. -
Little endian & big endian format system
Hi,
I have code which works fine for Little endian format system, can somebady please tell how to get data from big endian format system.
or is sap has setting where i can turn on and than run my code on that system.
Thanks,
John.hi
chk this
OPEN DATASET dset IN LEGACY TEXT MODE [(BIG|LITTLE) ENDIAN] [CODE PAGE cp]
Effect
Data is read or written in a form which is compatible to BINARY MODE in Releases <= 4.6. This addition is primarily used to convert a file into the code page format specified already when it is opened. At runtime, the system uses the format of the system code page of the application server. The system saves the file then again in the code page specified. This procedure is important if data is exchanged between systems using different code pages. For more information, see READ DATASET and TRANSFER.
Notes
on BIG ENDIAN, LITTLE ENDIAN
These additions specify the byte sequence in which to store numbers (ABAP types I, F, and INT2) in the file.
These additions may only be used in combination with the additions IN LEGACY BINARY MODE and IN LEGACY TEXT MODE. If these are not specified, the system assumes that the byte sequence determined by the hardware of the application server is used in the file.
If the byte sequence specified differs from that determined by the hardware of the application server, READDATASET and TRANSFER make the corresponding conversions.
These additions replace the language element TRANSLATE ... NUMBER FORMAT ... which must not be used in Unicode programs.
on CODE PAGE cp
This addition specifies the code page which is used to represent texts in the file.
This addition may only be used in combination with the additions IN LEGACY BINARY MODE and IN LEGACY TEXT MODE. If this addition is not specified, the system uses the code page defined by the text environment current at the time a READ or TRANSFER command is executed (see SET LOCALE LANGUAGE).
This addition replaces the language element TRANSLATE ... CODE PAGE ... which must not be used in Unicode programs.
open datset ... IN LEGACY BINARY MODE [(BIG|LITTLE) ENDIAN] [CODE PAGE cp]
Effect
Data is read or written in a form which is compatible to BINARY MODE in Releases <= 4.6. This addition is primarily used to convert a file into the code page format specified already when it is opened. At runtime, the system uses the format of the system code page of the application server. The system saves the file then again in the code page specified. This procedure is important if data is exchanged between systems using different code pages. For more information, see READ DATASET and TRANSFER. -
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,
Mattint 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.
Maybe you are looking for
-
Could I have damaged my hard drive?
Yesterday I was moving my router and cable modem around my desk, and, to make a long story short, some cables were tangled and a small desk lamp took a four-foot swan dive onto my MacBook Pro. The point of impact was about two inches below the keyboa
-
How to restore (not duplicate) DB from RAC ASM to non ASM
Hello everybody, i am trying to recover db from RAC+ASM to non ASM no RAC node. I am running Oracle 10g (10.2.0.4) on Win2003 Server. I have functional backup from my prod system. Here are my steps: *1. On prod server i make backup running this scrip
-
Unable to Center Page using CS3
At http://www.theforrestproject.org/xindex.html I have spent many hours trying to center this page in a browser. I am satisfied that the text and horizontal navigation bar are centered about themselves but when viewed in a browser they are off-center
-
Default of Profit Center in the Documents on the Basis of GL Accounts
Hoe to default the profit center in the Documents on the basis of the GL Accounts.
-
debit from itunes account but nothing in purchase history - where do you find out withdrawal?