Quote Originally Posted by visharad
I do not think it says anything about the school where Lindberg has studied. The problem is that the way we do mathematical calculations on paper and the way we write programs for that are often different. In the context of this thread, consider %. In Mathematics, we know that % means percentage, but in C++, it means remained when one integer is divided by another.
Yup it is different but what do you have to say about someone who did not understand: "number times .1555". 5 times 5 is equal to = ?
Quote Originally Posted by visharad
Several years back, when I first learnt about computer programming (it was Fortran 77), then I was surprised that there is an upper limit to integer. From Mathematics, I had learnt that there is no upper limit to integer. :-)
Yes, there is no limit to integer. But when you would do calculations on paper.. did the size of the paper restrict you for the maximum value? You could only write a number to fit the paper (or say 2/3 sheets joined together) but still there is a limitation on that. Isn't there? The same is with computers. It is not really that unbelievable.
Quote Originally Posted by visharad
Just a few days back, I was writing a program in VB where I had to calculate probability using Binomial distribution. It requires factorial. Using paper and pen I can do calculations in a very short time but my program was failing even though the sample size was as small as 30. I tried integer, long and even currency data type. For very high precision and to store large numbers, currency data type is used in VB. That also did not help. Then I used Sterling approximation to find factorials. That worked for sample size upto 50. Then I did lots of other optimizations and could somehow make it work for sample size of 3,500.
Discussing VB in VC++ does not make much sense. I bet if you wrote a factorial program in C++, it would work faster than you can think assuming you don't remember the direct value. For example if you are calculating 10! so that will be equal to 10*9*8*7*6*5! Now, for a human being memory comes into play... if you know 5! you can directly put its value but computers do computation. Moreover, you can use this with programs as well... and terminate the factorial call to 5! substituting its value. Plus it depends on what code you actually wrote.