How to perform mathematical operations on number represented as string in c++? How do I store number larger than c++ numerical? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

How to perform mathematical operations on number represented as string in c++? How do I store number larger than c++ numerical?

C++ question

10th May 2021, 12:37 AM
BlackChar
BlackChar - avatar
2 Respostas
+ 1
In order to deal with huge numbers, you can either use a custom user defined datatype ( string , arrays etc ) to store them and then create functions to perform calculation on them manually or use an external library like gnu's multiple precision arithmetic library to do that for you. Here's a simple implementation of bignum calculator used to calculate value of large Fibonacci numbers that I created for one of the community challange here on SL šŸ‘‡ https://code.sololearn.com/c7iD3WKd84RP/?ref=app
10th May 2021, 3:39 AM
Arsenic
Arsenic - avatar
0
#include<stdio.h> int main() { const char *str = "12345"; int x; sscanf(str, "%d", &x); printf("\nThe value of x : %d", x); return 0; }
10th May 2021, 12:57 AM
Alfonso FarĆ­as
Alfonso FarĆ­as - avatar