file i/o of a unsigned 64 or 128 bit interger

Started by
10 comments, last by vaneger 20 years, 1 month ago
how do i convert those larger integers to a format that will allow me to output them? i cant seem to find it in msdn for some reason. also what are the max values for those?
Advertisement
Exactly what types are you using?

The maximum number of discreet values = 2^n-1 where n is the number of bits and 2^n is 2 raised to the nth power. The largest value will depend on whether the number is signed or not. In the case of unsigned int's it's 18446744073709551615 and 3.4028236692093846346337460743177e+38.

[edited by - Solo on March 17, 2004 11:51:47 PM]
// Ryan
quote:Original post by Solo
Exactly what types are you using?

The maximum number of discreet values = 2^n-1


No. The max number of descreet values = 2^n, however this includes the integer value of 0, so the maximum unsigned number is 2^n-1

[edited by - Doc on March 17, 2004 12:10:08 AM]
My stuff.Shameless promotion: FreePop: The GPL god-sim.
quote:Original post by Doc

No. The max number of descreet values = 2^n, however this includes the integer value of 0, so the maximum unsigned number is 2^n-1


Oops.
// Ryan
OP: So what types (__int64 or something?) and what IO functions (fwrite/iostreams?) are you using? Chances are you can just give the functions the address of the variable and tell them to write 8 or 16 bytes (depending on the type). Exactly how to do that depends on the types and the functions.
My stuff.Shameless promotion: FreePop: The GPL god-sim.
well im currently using unsigned __int64 but if the code works for unsigned __int128 ill end up using that. for output im using fstream (ofstream, ifstream) how do i make those output a variable of that type cus when i go
ofstream fout;fout.open("etc",etc);fout<<some unsigned __int64<<endl;

it says fout operator ambigous :-\
so any help guys?
shouldnt that be (2 ^ 2n) - 1 as in a unsigned int being 8 bits and thus (2 ^ 16) - 1 = 65535?
unsigned short is 16 bits, 0 to 65535. unsigned int is 32 bits, 0 to 4294967295. Ints take 4 bytes (on 32 bit/modern windows systems).
i was confusing bytes and bits whoops, but still how do i get the larger oens to output properly?

This topic is closed to new replies.

Advertisement