473,397 Members | 2,068 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,397 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 4039
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.