Thread: Calculating S in C task

  1. #61
    Registered User
    Join Date
    May 2008
    Location
    Australia
    Posts
    230
    Quote Originally Posted by claudiu View Post
    Haha. Actually he was complaining a few posts ago that his "IQ dropped by 20 points" meaning it is now negative.
    I wonder if he can make a program to calculate his IQ. Since he's got a magic algorithm to hold values over the data types capacity I guess it would be able to hold his negative centillion IQ.
    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.

  2. #62
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Quote Originally Posted by Overworked_PhD View Post
    I just read your PM. I'm going to send over the code, along with the explanation, to your email. Just don't post it here.
    The email address you gave me just bounced. I'm going to send it over to you via PM.

  3. #63
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    > Here is what I get on my 32 bit PC. Please note that I'm not using any kind of multiprecision library.
    What's your point?
    Garbage in is garbage out perhaps.

    > The factorial of i 22 is: 1124000727777607680000
    > The factorial of i 23 is: 25852016738884978212864
    Explain how multiplying 3 with 0 gets you 4.
    Factorials accumulate increasingly long tails of zeros - any simple desk check of the results would have spotted that one.

    Your results ceased being accurate when it sailed past what can be stored in unsigned long long (64 bits).

    Post your code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #64
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by pobri19 View Post
    I wonder if he can make a program to calculate his IQ. Since he's got a magic algorithm to hold values over the data types capacity I guess it would be able to hold his negative centillion IQ.
    Well, as you will soon learn most of his work is actually "stuff his co-worker thought or wrote". The guy is hilarious.

  5. #65
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by Salem View Post
    > Here is what I get on my 32 bit PC. Please note that I'm not using any kind of multiprecision library.
    What's your point?
    Garbage in is garbage out perhaps.

    > The factorial of i 22 is: 1124000727777607680000
    > The factorial of i 23 is: 25852016738884978212864
    Explain how multiplying 3 with 0 gets you 4.
    Factorials accumulate increasingly long tails of zeros - any simple desk check of the results would have spotted that one.

    Your results ceased being accurate when it sailed past what can be stored in unsigned long long (64 bits).

    Post your code.
    Brillliant!

  6. #66
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Quote Originally Posted by Adak View Post
    Overworked_PhD, you have a PM.
    I just PMed you the code along with explanation. Just don't post the PM on here.

  7. #67
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by Overworked_PhD View Post
    I just read your PM. I'm going to send over the code, along with the explanation, to your email. Just don't post it here.
    I will respect your wishes, no problem.

    That account was hit today by the MalwareGen virus, and may not have gotten back on track, yet.
    Last edited by Adak; 04-20-2010 at 10:27 PM.

  8. #68
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Adak View Post
    I will respect your wishes, no problem.
    Salem's already pointed out that his output is incorrect. So it doesn't really matter what his code is at this point.


    Quzah.
    Hope is the first step on the road to disappointment.

  9. #69
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Quote Originally Posted by Adak View Post
    I will respect your wishes, no problem.
    Thank you.

  10. #70
    Registered User
    Join Date
    Mar 2009
    Posts
    23
    Quote Originally Posted by quzah View Post
    Salem's already pointed out that his output is incorrect. So it doesn't really matter what his code is at this point.


    Quzah.
    Funny how he simply overlooked that post...

  11. #71
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    By all means, if you have something better, post it.

  12. #72
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Really anything at this point is "something better" because your output was said to be faulty. At that point, it stopped being amusing. No one else here claimed to be able to fit 158 digit numbers in 32 bits and 10 lines of code.


    Quzah.
    Hope is the first step on the road to disappointment.

  13. #73
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    Quote Originally Posted by Overworked_PhD View Post
    By all means, if you have something better, post it.
    The fact that we don't have anything better doesn't justify your code is completely wrong.

    In fact, if you really wanted to compute such large factorials the only way I can imagine doing it is by using vectors to store digits individually and performing each multiplication between the digits manually, thus storing the huge result in another vector of digits, rather than in some integer type variable. However, that is a very tedious and complex operation and I will be impressed to see that written in 10 lines of code like you claimed.

  14. #74
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Okay, but it's funny how some of the people on here called me an idiot, yet these same people can't produce, in this case, a less buggy solution.

  15. #75
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Quote Originally Posted by quzah View Post
    Really anything at this point is "something better" because your output was said to be faulty. At that point, it stopped being amusing. No one else here claimed to be able to fit 158 digit numbers in 32 bits and 10 lines of code.


    Quzah.
    I wasn't talking to you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-31-2007, 11:40 AM
  2. Where do a task get "wakeuped", blocked, preempted?
    By micke_b in forum Linux Programming
    Replies: 4
    Last Post: 12-28-2007, 04:49 PM
  3. A Task Buffer for storing socket descriptors
    By cloudy in forum Networking/Device Communication
    Replies: 0
    Last Post: 09-09-2006, 01:08 PM
  4. Calculating : high numbers
    By MiraX33 in forum C++ Programming
    Replies: 9
    Last Post: 06-08-2006, 11:08 PM
  5. Recursion
    By Lionmane in forum C Programming
    Replies: 11
    Last Post: 06-04-2005, 12:00 AM