| jake eum (40) | |
|
if I'm dealing with a very large number some one advice me use string instead long long(or other ) for example string temp ="012345"; but my program need to change the value in certain condition such as temp[3] = temp[3]+1; but i guess this is not working. any one knows other methods for string to accomplish this goal? | |
|
|
|
| Athar (4466) | |||
This "works", although it depends on what you're trying to accomplish.
So what is your goal? If you want to deal with large numbers, use GMP. | |||
|
Last edited on
|
|||
| viliml (791) | ||
It is most certanly working, but unly untill you hit 10. | ||
|
|
||
| JLBorges (1754) | ||||
|
An obvious (though not efficient) way would be to simulate digit by digit addition with carry. Something like:
For real life code:
| ||||
|
|
||||
| Galik (2239) | |
|
This library is awesome and does exactly what you are looking for: http://gmplib.org/ | |
|
|
|
| modoran (1245) | |
| GMP or MPIR, depending of wahat compiler are you using. In windows GMP does not compile with Visual Studio, you must use MSYS and MinGW. | |
|
|
|
| jake eum (40) | |
|
I'm using Xcode. and working an UVA problems. is online judge accept the GMP lib? | |
|
Last edited on
|
|
| Duoas (6752) | |
|
I haven't looked through the UVa site, but I doubt that GMP will be accepted. I also don't think you need it. Remember, '0'..'9' is the same as 0..9, except that, for example, '7' is the same as '0'+7. | |
|
|
|