Explain this C code in english

This is a discussion on Explain this C code in english within the C Programming forums, part of the General Programming Boards category; Is there any php code that could display the full value of a number such as -6.36165918672933E+84? Or maybe even ...

  1. #16
    Registered User
    Join Date
    Aug 2006
    Posts
    19
    Is there any php code that could display the full value of a number such as -6.36165918672933E+84?

    Or maybe even php code that could replicate this entire deal?

    So like if I went to: www.website.com/convert.php?string=ABCDEFGHIL

    ..it would echo 884373937 on the page?

    I know php is probably more powerful and flexible than VB, so I could give it a shot there. But then I may just find myself going to a php forum.

  2. #17
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    ....-6.36165918672933E+84?
    Probably not. All languages are assembly when it comes down to the final product. There is no assembly data type nor CPU data type that can completely handle that value without using approximation. The double data type would be the only one that could even come close. Perhaps a 128-bit floating point value could handle that but since no higher level languages support it, you would still be losing precision and/or employing techniques to split the number up into smaller segments and then use those segments to compose the final value.

    Quite simply that value will not fit in any CPU register and I'm not even sure it would fit in any MMX register. It would probably fit in floating point registers (ST0 - ST7) but again it would be an approximation.

    You would need a class that handles large numeric values to handle that value correctly.

    And I think you are misusing the code:

    Code:
    int gs_chresp_num(char *challenge) {
        int     num = 0;
    
        while(*challenge) {
            num = *challenge - (num * 0x63306CE7);
            challenge++;
        }
        return(num);
    }
    This won't code an entire string. You are re-assigning a value to num each time. This will only encode the last character of challenge.

    This will encode the entire string, albeit will completely overflow the int data type.

    Code:
    int gs_chresp_num(char *challenge) {
        int     num = 0;
    
        while(*challenge) {
            num += *challenge - (num * 0x63306CE7);
            challenge++;
        }
        return(num);
    }
    The operation done on num in this loop is essential to whether or not the data type overflows. Are you sure they are not doing some type of bitwise operations on num like:

    Code:
    num |= *challenge - (num * 0x63306CE7);
    or
    Code:
    num ^= *challenge - (num * 0x63306CE7);
    or

    Code:
    num &= *challenge - (num * 0x63306CE7);
    This code looks something like a simple XOR encryption method that you are misusing.

    Also remember that any language can be powerful, but all languages are only as powerful as the one using it.
    Last edited by VirtualAce; 08-31-2006 at 01:57 AM.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someone explain this code?
    By Sharke in forum C++ Programming
    Replies: 3
    Last Post: 06-18-2009, 01:12 PM
  2. Could someone explain this code for me please...
    By JoshR in forum C++ Programming
    Replies: 89
    Last Post: 06-26-2005, 02:20 AM
  3. Seems like correct code, but results are not right...
    By OmniMirror in forum C Programming
    Replies: 4
    Last Post: 02-13-2003, 01:33 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21