473,326 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

raw byte representation of unsigned long long?

Hi,
I encountered a problem involving storage of unsigned long long. The
requirement of incoming data field is an unsigned 64-bit integer, but
on our system, due to lack of support of 64-bit integer from Oralce
pro-C(it only supports 32-bit integer). We have to find a way to get
around it. I am wondering whether there is other way to store big int
in kind of 8-byte raw data and later convert it to 64-bit integer. Is
the raw data has to be stored as C-string? Certainly, we can use
double, but I like to know whether we have other option or not. thx

Nov 8 '06 #1
3 4030
we*****@yahoo.com wrote:
I encountered a problem involving storage of unsigned long long. The
requirement of incoming data field is an unsigned 64-bit integer, but
on our system, due to lack of support of 64-bit integer from Oralce
pro-C(it only supports 32-bit integer).
Switch compilers.
We have to find a way to get around it. I am wondering whether there
is other way to store big int in kind of 8-byte raw data [..]
Sure, just store it in eight bytes (uint8_t or unsigned char).
[..]and later convert it to 64-bit integer.
How so, if there is no 64 bit integer type?

I'm not sure where your problem is, but remember that after all any object
is stored as a sequence of bytes. The much more interesting part is what
you want to do with the integer. If you only need to store it or move it
around, just use a struct containing an array of eight octets or
equivalent. If you need to do arithmetic with it, you might consider
splitting it into two parts of 32 bit each.
Is the raw data has to be stored as C-string? Certainly, we can use
double, but I like to know whether we have other option or not.
Why would you store it as C string? It is not text and it surely is not
terminated by a trailing NUL.

Further, I don't think double can be used to store 64 bit integral numbers
(at least not without discarding some digits), but long double might
be. "might be" because it is possible that long double is no bigger than
double.

Uli

Nov 8 '06 #2
Our systemm does support uint64_t, the problem comes from Oracle Pro-C
code which doesn't support 64-bit integer. I can do following:
typedef unsigned char octet;
octet bigNum[sizeof(uint64_t)];
uint64_t myBigNum = 1000;
memcpy(&bigNum, &myBigNum, sizeof(myBigNum));
the corresponding field at Oracle DB table is defined as a number, the
only question left is whether DB can enterpret 8 raw bytes as DB
number and store it correctly?
So, instead of using a uint64_t we can use octet[] instead if it works.
Ulrich Eckhardt wrote:
we*****@yahoo.com wrote:
I encountered a problem involving storage of unsigned long long. The
requirement of incoming data field is an unsigned 64-bit integer, but
on our system, due to lack of support of 64-bit integer from Oralce
pro-C(it only supports 32-bit integer).

Switch compilers.
We have to find a way to get around it. I am wondering whether there
is other way to store big int in kind of 8-byte raw data [..]

Sure, just store it in eight bytes (uint8_t or unsigned char).
[..]and later convert it to 64-bit integer.

How so, if there is no 64 bit integer type?

I'm not sure where your problem is, but remember that after all any object
is stored as a sequence of bytes. The much more interesting part is what
you want to do with the integer. If you only need to store it or move it
around, just use a struct containing an array of eight octets or
equivalent. If you need to do arithmetic with it, you might consider
splitting it into two parts of 32 bit each.
Is the raw data has to be stored as C-string? Certainly, we can use
double, but I like to know whether we have other option or not.

Why would you store it as C string? It is not text and it surely is not
terminated by a trailing NUL.

Further, I don't think double can be used to store 64 bit integral numbers
(at least not without discarding some digits), but long double might
be. "might be" because it is possible that long double is no bigger than
double.

Uli
Nov 8 '06 #3
"we*****@yahoo.com" <we*****@yahoo.comwrites:
Our systemm does support uint64_t, the problem comes from Oracle Pro-C
code which doesn't support 64-bit integer. I can do following:
typedef unsigned char octet;
octet bigNum[sizeof(uint64_t)];
uint64_t myBigNum = 1000;
memcpy(&bigNum, &myBigNum, sizeof(myBigNum));
the corresponding field at Oracle DB table is defined as a number, the
only question left is whether DB can enterpret 8 raw bytes as DB
number and store it correctly?
[...]

If that's the only question left, then you're asking it in the wrong
place.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: w3r3w0lf | last post by:
hello! I have a following situation: I have a byte array where at a certain location are stored 4 bytes, and these should be "put" into long variable (or any other 4 byte one). ie: byte...
19
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
14
by: Magix | last post by:
I received byte by byte 0x8E byte1 0x3D byte2 0x64 byte3 0x5F byte4 How can I construct to be LONG 0x645F8E3D (shift left >> 16) Thanks.
33
by: Benjamin M. Stocks | last post by:
Hello all, I've heard differing opinions on this and would like a definitive answer on this once and for all. If I have an array of 4 1-byte values where index 0 is the least signficant byte of a...
4
by: Frederick Gotham | last post by:
What do you think of the following code for setting and retrieving the value of bytes in an unsigned integer? The least significant bit has index 0, then the next least significant bit has index 1,...
4
by: msosno01 | last post by:
I have Java client that connects to C++ server. The client sends integer in binary using DataOutputStream write function. I am reading these data into buffer. I have to convert this buffer back...
24
by: Frederick Gotham | last post by:
There is a thread currently active on this newsgroup entitled: "how to calculate the difference between 2 addresses ?" The thread deals with calculating the distance, in bytes, between two...
7
by: dana_livni2000 | last post by:
how do i print the acuale byte sequence that represent a vairable (let say a char - i want to see the 8 bits). thanks dana
77
by: borophyll | last post by:
As I read it, C99 states that a byte is an: "addressable unit of data storage large enough to hold any member of the basic character set of the execution environment" (3.6) and that a byte...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.