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

+103

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. https://github.com/sercantutar/infint https://code.sololearn.com/caP8649IZ2fH/?ref=app https://code.sololearn.com/cQKjPRAb6JcZ/?ref=app

4/13/2018 8:32:07 AM

AliR૯za

60 Answers

New Answer

+24

Congratulations, you made me write code. https://code.sololearn.com/cqtn357OfStn/?ref=app

+117

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: https://code.sololearn.com/c81HCw3Wbohj/#cpp

+64

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++.

+30

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.

+28

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

+23

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 😉

+23

Hatsy Rei awesome 👍

+22

wd00009 thank you 😄❤

+20

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.

+18

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

+18

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

+18

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

+17

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

+17

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

+16

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

+16

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

+14

OMG i should learn phython soon.

+13

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

+12

You could also write READABLE python programmes https://code.sololearn.com/cn5faURSpwLi/?ref=app

+10

this doesn't contain 64 lines https://code.sololearn.com/cyn8jnfcr9pW/?ref=app