473,785 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4074
we*****@yahoo.c om 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.c om 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_Keit h) 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
3272
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 a={0x0,0x0,0xfe,0x30,0x9e,0x2,0x66,0,0} and the bytes 0xfe,0x30,0x9e,0x2 should be put into long variable which should then contain 43921662 how to achieve this?
19
4153
by: jeff | last post by:
how do you convert form byte to Int32 while retaining the binary value of the byte array
14
2977
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
3416
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-byte value. Can I use the arithmatic shift operators to hide the endian-ness of the underlying processor when assembling a native 4-byte value like follows: unsigned int integerValue; unsigned char byteArray;
4
2215
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, and so on. The code computes at runtime the byte-order of the unsigned integer, but alas it would be better if it could be determined at compile-time. The code potentially invokes undefined behaviour if an unsigned integer contains padding bits....
4
41625
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 into integer, but I am not sure how to do it. This is my code: int32_t var1; uint8_t buf;
24
2787
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 memory addresses. Obviously, this can only be done if the addresses refer to elements or members of the same object (or base objects, etc.). John Carson and I proposed two separate methods.
7
3467
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
4300
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 must be at least 8 bits: "The values given below shall be replaced by constant expressions suitable for use in #if
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10329
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8974
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.