Public Group

#### Archived

This topic is now archived and is closed to further replies.

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

This topic is 5238 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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?

##### Share on other sites
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]

##### Share on other sites
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]

##### Share on other sites
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.

##### Share on other sites
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.

##### Share on other sites
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 :-\

##### Share on other sites
so any help guys?

##### Share on other sites
shouldnt that be (2 ^ 2n) - 1 as in a unsigned int being 8 bits and thus (2 ^ 16) - 1 = 65535?

##### Share on other sites
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).

##### Share on other sites
i was confusing bytes and bits whoops, but still how do i get the larger oens to output properly?

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• ### Forum Statistics

• Total Topics
631782
• Total Posts
3002332
×