Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Working with large numbers

Name: Anonymous 2010-09-27 19:45

I'm creating a program in C that factors a really, really large number(600851475143). What data type should I be using?
Also, my compiler told me that I cannot use the modulus operator with the previously stated number and long type number. How do I fix this?

Name: Anonymous 2010-09-27 19:47

Use long long, and declare the number as 600851475143LL

Name: Anonymous 2010-09-27 19:53

>>2
Thanks for the help, friend!

Name: Anonymous 2010-09-27 19:53

use an arbitrary-precision number library

Name: Anonymous 2010-09-27 21:22

GMP. or BigInteger of java. Or just python. java nad python are slow though. But, who cares?

Name: Anonymous 2010-09-27 21:32

http://pastebin.com/xcFgjmsj
Please critique my code.
Disclaimer: I am a faggot.

Name: Anonymous 2010-09-27 23:11

#include <low_primes.h> //Adds an array of primes (long) low_primes[];
IFUCKINGHBT

Name: Anonymous 2010-09-28 1:44

>>6
//No space between ``//'' and the comment text
JAVA101 programmer

Name: Anonymous 2010-09-28 10:40

>>8
That was the worst you noticed, was it?

Name: Anonymous 2010-09-28 10:41

>>6
FUCK YOU

#include <stdio.h>
#include <low_primes.h> //Adds an array of primes (long) low_primes[];

main()
{
    long factors[40];
    long long number = 600851475143LL;
    int i = 0;
    int n = 0;
   
    while (low_primes[i] != 99991)
    {
        if(number%low_primes[i] == 0)
        {
            factors[i] = low_primes[i];
            number/=low_primes[i];
        }
        if(number == 1 | number == 0)
        {

            while (n < 40)
            {
                printf("%l", factors[n]);
                n++;
            }
            break; // BECAUSE FUCK YOU GOTO
                   // PIG DISGUSTING!!!

        }
        i++;
    }
//  BREAK:
//      while (n < 40)
//      {
//          printf("%l", factors[n]);
//          n++;
//      }
    return 0;
}

Name: Anonymous 2010-09-28 10:45

fuck you considered harmful

Name: Anonymous 2010-09-28 10:48

>>10
You haven't even come close to fixing the worst of it, you twit.

Name: Anonymous 2010-09-28 10:54

>>10
I used a break yesterday.  It didn't feel good at all.

Name: Anonymous 2010-09-28 10:55

>>10
break is considered harmful for the same reason goto is, idiot. Read the fucking paper.

Name: Anonymous 2010-09-28 10:58

>>14
You'd rather put all conditions for breaking out of a loop in its head?

Name: Anonymous 2010-09-28 10:59

>>14
break and goto both have their place. Look at any OS code. goto is used in a lot of places.

Name: Anonymous 2010-09-28 11:10

>>6
That code has so many problems that I don't even want to start listing them.

Name: Anonymous 2010-09-28 11:11

``considered harmful'' considered harmful

Name: Anonymous 2010-09-28 11:12

>>17
Looking at his code makes me feel better about mine.

Name: Anonymous 2010-09-28 11:39

goto BREAK;
IHBT.

Name: Anonymous 2010-09-28 13:13

>>15
Read the fucking paper.

Name: Anonymous 2010-09-28 13:17

>>21
Flow control considered harmful?

Name: Anonymous 2010-09-28 13:48

>>22
Read the fucking paper.

Name: Anonymous 2010-09-28 15:09

>>9
It was the first thing I noticed.

Name: Anonymous 2010-09-28 16:20

>>23
Fuck reading the paper.

Name: Anonymous 2010-09-28 16:26

>>6
here.
I apologize for my use of goto, I understand that it creates spaghetti code on occasion. Thanks to >>10 for helping me tackle my problem.
Please calm down, I even included a disclaimer in my post.

Name: Anonymous 2010-09-28 17:19

>>26
It's not your use, but your misuse. Any use of goto where anything else that's not incredibly awkward would have worked is misuse; every other use may be ok.

>>10
You helped him!!

Name: Anonymous 2010-12-24 15:47

Name: Anonymous 2011-01-30 1:32

>>26-29
Read the fucking paper.

Name: Anonymous 2011-01-30 1:33

>>30
Fuck the paper. Literally, though. And take pictures please.

Don't change these.
Name: Email:
Entire Thread Thread List