challenge for infinitely sized integer in C++

Programming, for all ages and all languages.
Post Reply
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

challenge for infinitely sized integer in C++

Post by AndrewAPrice »

I challenge someone to make a class in C++ that can hold any specified-sized variable like:

var<bool float, int size>

Therefore an int would be:
var<false,32>

A short would be:
var<false,16>

A float would be:
var<true,16>

Although this isn't useful for standard sizes (16,32,64-bit) but when dealing with odd sizes like 96-bit and even 2048-bit+ numbers.
My OS is Perception.
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

even i can wrap something up which can hold "infiniti" sized intefers. The deficult part is putting the value in, and getting it out again.
fx.
std::bitset<somenumber> B
and then set all the bits manually ;)
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Post by jnc100 »

Gmp has a c++ interface.

Regards,
John.
Post Reply