Duta's Profile User Rating: -----

Reputation: 3 Apprentice
Group:
Members
Active Posts:
43 (0.05 per day)
Joined:
21-June 12
Profile Views:
2,740
Last Active:
User is offline Nov 17 2012 04:28 PM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Icon   Duta has not set their status

Posts I've Made

  1. In Topic: I'm so embarassed

    Posted 1 Nov 2012

    View Postcarnivroar, on 31 October 2012 - 08:25 PM, said:

    View PostDuta, on 30 October 2012 - 04:01 AM, said:

    View Postcarnivroar, on 25 July 2012 - 02:49 PM, said:

    Really? Whew, then. At my school Python is taught at the first programming course, and only that one. I think that because of that some professors there think of it as more elementary than other languages, which made me look inexperienced when I said Python was superior for math.

    View Poststackoverflow, on 25 July 2012 - 01:40 PM, said:

    (complicated processes that you have to manually take care of when doing the same thing) == crap

    :)


    Then I wont show you my assembly program that finds 100 factorial. :whistling:

    Though slightly off topic, post the code for your assembly program? :)


    Yayyy I missed assembly language. It made my Summer 2012. Finds the sum of all digits in 100! :

    #------------------------------------------------------------------------------
    # PROJECT EULER
    # PROBLEM 20
    #------------------------------------------------------------------------------
    # n! means n * (n * 1) * ... * 3 * 2 * 1
    #
    # For example, 10! = 10 * 9 * ... * 3 * 2 * 1 = 3628800,
    # and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
    #
    # Find the sum of the digits in the number 100!
    #------------------------------------------------------------------------------
    # SOLUTION: 648
    #------------------------------------------------------------------------------
    # as -32 20.s -o 20.o
    # gcc -m32 20.o -o 20
    #------------------------------------------------------------------------------
    
    dec32_format:
        .string "%d\n"
    
    .section .text
    .globl main
    
    main:
        pushl   $100                             # function parameter
        call    find_sum_of_digits_in_factorial
        pushl   %eax                             # function output
        call    print32
    
    #------------------------------------------------------------------------------
    main_exit:
        xor     %eax, %eax
        incl    %eax
        xor     %ebx, %ebx
        int     $0x80
    
    #------------------------------------------------------------------------------
    .type print32, @ function
    
    print32:
        pushl   4(%esp)
        pushl   $dec32_format
        call    printf
        addl    $8, %esp
        ret
    
    #------------------------------------------------------------------------------
    .type find_sum_of_digits_in_factorial, @ function
    
    find_sum_of_digits_in_factorial:
        pushl   %ebp                # save base pointer
        pushl   $1                  # first number in factorial
        pushl   $-1                 # flag end of number
        addl    $4, %esp            # move back behind flag
        xor     %ebx, %ebx          
        addl    $10, %ebx           # we'll use this 10 to single out carries
        xor     %edi, %edi
        addl    12(%esp), %edi      # function parameter
    
    fsodif_main_loop:
        cmpl    $1, %edi            # factorial is done computing?
        jle     fsodif_done         # go get ready to add the digits
        decl    %edi                # else decrement paramter
        movl    %esp, %ebp          # copy of stack pointer
        xor     %edx, %edx 
        xor     %ecx, %ecx
    
    fsodif_multiply_loop:
        cmpl    $-1, (%ebp)           # check for flag
        jne     fsodif_ml_continue    # no flag yet, multiply again
        cmpl    $0, %ecx              # else check if there's a carry
        je      fsodif_main_loop      # no carry, back to main loop
        movl    %ecx, %eax            # yes carry, need to propagate it
    
    fsodif_ml_propagate_carry:             # pushes each digit of carry
        xor     %edx, %edx                 # to the next stack location
        div     %ebx                       # gets carry in eax
        movl    %edx, (%ebp)               # move remainder to current location
        addl    $-4, %ebp                  # move to the next adress
        cmpl    $0, %eax                   # is there still a carry?
        jne     fsodif_ml_propagate_carry  # then do it again
        movl    $-1, (%ebp)                # else push flag back in before leaving
        jmp     fsodif_main_loop 
    
    fsodif_ml_continue:
        movl    (%ebp), %eax          # gets current value in stack address
        mul     %edi                  # multiply it by factorial (n..1)
        addl    %ecx, %eax            # carry from previous multiplication
        div     %ebx                  # get only 1 digit
        movl    %edx, (%ebp)          # move that digit to current stack address
        movl    %eax, %ecx            # ecx holds the current carry
        addl    $-4, %ebp             # shift go to next stack
        jmp     fsodif_multiply_loop  # go back to multiply loop
    
    fsodif_done: 
        xor     %eax, %eax          # sum
        movl    %esp, %ebp          # copy of stack pointer - start at beginning
    
    fsodif_add:    
        cmpl    $-1, (%ebp)         # check for flag
        je      fsodif_exit         # if we've arrived at the flag, we're done
        addl    (%ebp), %eax        # else add
        addl    $-4, %ebp           # move to the next stack address
        jmp     fsodif_add          # do it again
    
    fsodif_exit:
        addl    $4, %esp            # restore stack pointer
        popl    %ebp                # restore base pointer
        ret
    
    

    Cool :)
    By the way, the line:
    n! means n * (n * 1) * ... * 3 * 2 * 1
    

    should be
    n! means n * (n - 1) * ... * 3 * 2 * 1
    

    Its in a comment though so not _too_ important.
  2. In Topic: I'm so embarassed

    Posted 30 Oct 2012

    View Postcarnivroar, on 25 July 2012 - 02:49 PM, said:

    Really? Whew, then. At my school Python is taught at the first programming course, and only that one. I think that because of that some professors there think of it as more elementary than other languages, which made me look inexperienced when I said Python was superior for math.

    View Poststackoverflow, on 25 July 2012 - 01:40 PM, said:

    (complicated processes that you have to manually take care of when doing the same thing) == crap

    :)


    Then I wont show you my assembly program that finds 100 factorial. :whistling:

    Though slightly off topic, post the code for your assembly program? :)
  3. In Topic: [Lua] Is my code good Lua style?

    Posted 29 Oct 2012

    Thanks ishka, that was really useful :)
    I tried changing Util:concat and Util:printtable to Util.concat and Util.printtable (in the function declarations and the uses), however doing that gives me the output:
    ||||
    ||||
    ||||
    ||||
    

    Whereas normally I get:
    |------|-------|-----|-----|
    |Name  |Level  |Class|Race |
    |------|-------|-----|-----|
    |Painrc|25     |Rogue|Orc  |
    |Geoff |90     |Mage |Gnome|
    |Anon  |Unknown|/b/  |4chan|
    |------|-------|-----|-----|
    

    Any ideas?
    Also, I didn't mean to include the Character:isHorde function as I don't use it, but good point. I wasn't happy with it as it stood :)
    Finally, how would you overload the call operator?
  4. In Topic: My site

    Posted 29 Oct 2012

    All I see is the text 'Yo', but as a design on the whole, I like it. Really not enough there right now for me to comment on.

My Information

Member Title:
New D.I.C Head
Age:
19 years old
Birthday:
March 24, 1995
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

Duta hasn't added any friends yet.

Comments

Duta has no profile comments yet. Why not say hello?