27 users online (1 members and 26 guests)  


  Results 1 to 8 of 8

Related

  1. calculations using Javascript    Forum: Javascript Forum
    Replies: 2
  2. Form Does Calculations Problem    Forum: HTML Forum
    Replies: 9
  3. seperate whole number    Forum: Javascript Forum
    Replies: 1
  4. Number of Vertical Pixels    Forum: Graphics Forum
    Replies: 2
  1. #1
    gacooper's Avatar
    New User

    Status
    Offline
    Join Date
    May 2005
    Posts
    3

    Help required with number calculations

    Hi there,

    could someone have a look at the following perl code, I'm just trying to perform some arithmetic on some scalar variables, though I think there's a conversion problem from string to integer.

    PHP Code:
    $Forename $FORM{'txtForename'};
    $Surname $FORM{'txtSurname'};
    $Email $FORM{'txtEmail'};
    $Login $FORM{'txtLogin'};

    $IntCode $FORM{'txtIntCode'};
    $Intcode pack("I"$IntCode);

    $AreaCode $FORM{'txtArea'};
    $AreaCode pack("I",$AreaCode);

    $Phone $FORM{'txtPhone'};
    $Phone pack("I",$Phone);

    print <<
    EndOfHTML;

    <
    html><head><title>PAGE TITLE</title></head>

    $Forename <BR>
    $Surname <BR>
    $Email <BR>
    $Login <BR>
    $IntCode <BR>
    $AreaCode <BR>
    $Phone <BR><BR>

    EndOfHTML

    $password 
    $IntCode+$AreaCode+$Phone;

    $password $password Hex(IntCode);

    print 
    "<BR><BR> $password";

    print 
    "</body></html>"

  2. #2
    gacooper's Avatar
    New User

    Status
    Offline
    Join Date
    May 2005
    Posts
    3

    Unhappy Re: Help required with number calculations

    The calculations I'm performing on the scalar variables aren't working at all, and are just simply returning the value 0.

    I've tried to 'convert' the values to Integer using the pack function, which doesn't make any difference.

    If it's relevant at all, the script runs on Unix server.

    The results of the script are shown at the following page:

    osiris.sunderland.ac.uk/~ca3gco/LoginPage.htm

  3. #3
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662

    Re: Help required with number calculations

    Just at first glance (I'm not the perl expert round here) shouldn't:
    Hex(IntCode)
    be
    Hex($IntCode)
    ?
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  4. #4
    gacooper's Avatar
    New User

    Status
    Offline
    Join Date
    May 2005
    Posts
    3

    Re: Help required with number calculations

    I think you're right about that one, but it still doesn't seem to solve the problem. I was debuggin the script last night, and printed the result after every calculation, the problem was there before it got to that line!

  5. #5
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662

    Re: Help required with number calculations

    Hmm. Well, theres some Perl experts that post here so we can see if they see this.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  6. #6
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: Help required with number calculations

    ok, after looking at it for a while, i may have found it, but i cannot test it, because my computer is getting repaired; anyway, I am not sure about cgi/perl, but Integers have a maximum number of a little over 2.14 billion, and you are exceeding it(i believe), because lets say my number was:
    (555)555-1234, so the number would be 5,555,551,234 which is already over the integer limit; but you are still trying to calculations on it, by mulitplying and adding to it, which it cannot do, because it has already overfilled the variable.

    what you might try doing is converting it to a Long, or a Dubble, because Long has a maximum value of a over 9.2 quintillion (9,223,372,036,854,775,807), so you should be safe as long as they dont have some wierd really really long phone number, areacode, exc...

    that should do it,
    -ALL

    PS: i am no CGI/Perl expert, but i am fairly good at codding and debugging(in the languages i know).

  7. #7
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662

    Re: Help required with number calculations

    Quote Originally Posted by ALL
    PS: i am no CGI/Perl expert, but i am fairly good at codding and debugging(in the languages i know).
    You undersell yourself I've seen your answers
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  8. #8
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: Help required with number calculations

    Quote Originally Posted by QuietDean
    You undersell yourself I've seen your answers
    Thanks, but you have to realize, i have to look up many of the functions to find out what they do, and how to use them, because going from one language to another, the functions are used and called differently.

    but hey, thanks for the complement



Tags for this Thread