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

Pages: 1-

Call of Codethulhu

Name: BobTheCompiler 2011-03-09 17:45

Fellow /prog/rammers, I come to you with something I'm trying to clean up. Ages ago, I created an excel spreadsheet whose sole purpose was to convert base10 number to other bases (such as base13, which allows 6 x 9 to equal 42). Did it more out of boredom/challenge than anything else.

That same boredom hit me today and I converted the equations to C++. Issue? The code is so evil is practically stares back at you, deep into your soul. The whole purpose of the code right now is to extract digits: That is if I input 1234 it will push back out 1 2 3 4. Just the single digit in a particular place.
My question is: Has anyone ever tried to create a function like this, and is there a better way I can pull this off? The meat of the function is listed below.

/* int places is set in another part of the function, and will be the total number of digits. 1234 would have places set to 4 */
while (places)
{
 cout << "Place 10^" << places -1 << " Digit: " <<
 ((((input * 10) % (static_cast<int>(pow(base,places+1))))
 /static_cast<int>(pow(base,places))) *
 static_cast<int>pow(base,places)))
 /static_cast<int>pow(base,places)) << endl;

 places--;
}

Name: fuck you faggot 2011-03-09 17:46

fuck you faggot

Name: Anonymous 2011-03-09 17:47

>>1
That would be so easy in Lisp:
(define call/cthulhu call-with-cthulhu-invocation)
(call/cthulhu (lambda (cthulhu) ...))

Name: Anonymous 2011-03-09 17:49

>>1
mailto:noko

Name: Anonymous 2011-03-09 21:42

>>2

fuck you faggot

Name: Anonymous 2011-03-09 23:20

why not use log on base 10 instead of the "places" function?


Number       Log10
------     -----
1          0
9          0,954242509439325
10         1
11         1,04139268515823
123        2,0899051114394
1234       3,09131515969722
50006      4,69902211654718
99900001   7,99956549257327
99900009   7,99956552735161
99999999   7,99999999565706
100000001  8,00000000434295

Name: Anonymous 2011-03-09 23:26

>>6
Even better : places = number % 10

Name: Anonymous 2011-03-09 23:33

>>7
LOL wtf are u smoking

Name: smoke weed everyday 2011-03-09 23:35

smoke weed everyday

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