See the difference (BigInt in C++ and Python) | SoloLearn: Learn to code for FREE!


See the difference (BigInt in C++ and Python)

Rei: To clarify on OP's behalf: Python supports int values of arbitrary size, C++ does not. This is because Python focuses on achieving results quickly, while C++ primes in runtime performance, letting you decide the optimal structure to deal with BigInt. This thread is not an attack on C++. There are also well-written, ready-to-use C++ BigInt libraries online, e.g.

4/13/2018 8:32:07 AM


60 Answers

New Answer


Congratulations, you made me write code.


Sorry, but your C++ code is just overkill. You can do the same calculation in C++ with only 1 line of code and thereby reach a sufficient precision, too:


In programmer performance, Python is superior. In runtime performance C++ is superior. So the tool of choice for code that only needs to run occasionally is Python. When code needs to run often or runs on a battery powered device, you might want to consider C++.


Yes, you can easily calculate 40 numbers more. That's because Python doesn't have a native variable limit like C++ does. The limit has a reason though. C++ and Python are different languages with different strenghts used for different purposes, so there's no point in badmouthing a language because of something it wasn't built for. Such integer precision doesn't have any practical use in C++ applications and I can assure you that nobody read past the 10th number. You will never write 60 lines to get some extra precision in a calculation and you'll still get a good enough result. Furthermore, C++ calculates 94 Fibonacci numbers way faster than Python does. I see your point, but your statement is very misleading.


Chris totally my post has joking aspect , i want show a small limit can make the code too long And about function , it's very simple , i will write how it works in next few days


Chris & another thing It's not just 30 line code to calculate 40 another numbers that as you said nobody cares about that It's good training for beginners and for my future project 😉


Hatsy Rei awesome 👍


wd00009 thank you 😄❤


The thing is, you're nowhere explicitely telling that your statement is about the length of the numbers you're calculating. You're linking two codes called "Fibonacci series", saying that the C++ one is 60 times longer, and that's it. There's no mention about a joking aspect or what you are actually trying to achieve here. Yes, it's good training. But you're implicitely making people think that Python is superior by giving a false positive example.


Naman just read the comments in this post to understand why this contain 64 line


Costin Onciu anyway C has limit for variables even if using array or not


Freddy awesome idea but how can convert string to number ?! 🤔


Fistefalo серия чисел, в которых каждое число (число Фибоначчи) является суммой двух предыдущих чисел. Простейшим является ряд 1, 1, 2, 3, 5, 8,


phyton vs c++ is amazing coder its so wow magic


Chris you forgot one thing , that my code can calculate fibonacci series up to 141th number (not 94th as you wrote), i wrote 30 rows code to break that limit bro😉 #look_carefully #eyes_wide_shut goodluck


Fistefalo да, я делаю тот же код, но, к сожалению, в c ++, поскольку вы знаете, что у нас есть ограничение переменной, которое не может хранить верхние значения 18 * (10 ^ 18), поэтому я написал слишком длинный код, чтобы разбить этот предел и вычислить 141-е число фибоначчи с 30 цифр целых чисел :)


OMG i should learn phython soon.


Fistefalo я не понимаю, что вы имеете в виду !


You could also write READABLE python programmes


this doesn't contain 64 lines