See the difference (BigInt in C++ and Python) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

13th Apr 2018, 8:32 AM
AliR૯za
AliR૯za - avatar
60 Answers
+ 24
Congratulations, you made me write code. https://code.sololearn.com/cqtn357OfStn/?ref=app
18th Apr 2018, 5:34 AM
Hatsy Rei
Hatsy Rei - avatar
+ 118
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
13th Apr 2018, 7:12 PM
Chris
Chris - avatar
+ 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++.
13th Apr 2018, 3:51 PM
Freddy
+ 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.
13th Apr 2018, 9:33 PM
Chris
Chris - avatar
+ 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
13th Apr 2018, 9:46 PM
AliR૯za
AliR૯za - avatar
+ 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 😉
13th Apr 2018, 10:23 PM
AliR૯za
AliR૯za - avatar
+ 23
Hatsy Rei awesome 👍
18th Apr 2018, 8:03 AM
AliR૯za
AliR૯za - avatar
+ 22
wd00009 thank you 😄❤
17th Apr 2018, 12:42 PM
AliR૯za
AliR૯za - avatar
+ 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.
14th Apr 2018, 12:34 AM
Chris
Chris - avatar
+ 18
Naman just read the comments in this post to understand why this contain 64 line
14th Apr 2018, 4:29 AM
AliR૯za
AliR૯za - avatar
+ 18
Costin Onciu anyway C has limit for variables even if using array or not
14th Apr 2018, 9:51 AM
AliR૯za
AliR૯za - avatar
+ 18
Freddy awesome idea but how can convert string to number ?! 🤔
14th Apr 2018, 12:54 PM
AliR૯za
AliR૯za - avatar
+ 17
Fistefalo серия чисел, в которых каждое число (число Фибоначчи) является суммой двух предыдущих чисел. Простейшим является ряд 1, 1, 2, 3, 5, 8,
13th Apr 2018, 8:50 PM
AliR૯za
AliR૯za - avatar
+ 17
phyton vs c++ is amazing coder its so wow magic
17th Apr 2018, 4:32 AM
Nina Hendra Putri
Nina Hendra Putri - avatar
+ 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
13th Apr 2018, 8:03 PM
AliR૯za
AliR૯za - avatar
+ 16
Fistefalo да, я делаю тот же код, но, к сожалению, в c ++, поскольку вы знаете, что у нас есть ограничение переменной, которое не может хранить верхние значения 18 * (10 ^ 18), поэтому я написал слишком длинный код, чтобы разбить этот предел и вычислить 141-е число фибоначчи с 30 цифр целых чисел :)
13th Apr 2018, 9:26 PM
AliR૯za
AliR૯za - avatar
+ 14
OMG i should learn phython soon.
13th Apr 2018, 8:34 AM
🦋FEATHER🦋
🦋FEATHER🦋 - avatar
+ 13
Fistefalo я не понимаю, что вы имеете в виду !
13th Apr 2018, 8:45 PM
AliR૯za
AliR૯za - avatar
+ 12
You could also write READABLE python programmes https://code.sololearn.com/cn5faURSpwLi/?ref=app
15th Apr 2018, 10:14 PM
Loeschzwerg
+ 10
14th Apr 2018, 2:51 AM
Naman
Naman - avatar