Re: _ttoi function - checking return value



I think that you need to validate the user input, not your interpretation of
the input which you are showing can and will change the value if the user
input is out of range.

--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net

Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member

<ToeKneeSee@xxxxxxxxxxxxxx> wrote in message
news:2024c007-be4a-48c0-8548-ad6ae61fe3a7@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,

I'm using the "_ttoi" function to convert a user-input string into an
integer, and want to check that the user-entered value is within an
integer's range, by checking against INT_MIN and INT_MAX.

However, overflows can occur, so that for example 9999999999 results
in 1410065407 being returned by the _totoi function, which would
erroneously pass the " if( x >= INT_MIN && x <= INT_MAX ) " test.

Does anyone have any ideas how best to validate user-input such as
this?

Thanks for any help,

Tony.


.



Relevant Pages

  • Re: Perl output Javascript to validate user input
    ... 2- After user input, the javascript which embed with Perl script to ... So the Perl script merely prints out the Javascript source, ... need to validate on the server. ...
    (comp.lang.perl.misc)
  • Re: IN Clause - Stuck on an easy query :-(
    ... >validate or verify the data. ... not some unknown program to be written by an unknown ... The CHECKconstraints and REFERENCES also provide extra ... I'll give you credit for the novel concept: check user input by ...
    (microsoft.public.sqlserver.programming)
  • RE: How2 accept only numbers in userform textbox
    ... Write code to Validate the user input BEFORE you perform you math functions. ... Private Sub CommandButton1_Click ...
    (microsoft.public.excel.programming)
  • Re: Perl output Javascript to validate user input
    ... 2- After user input, the javascript which embed with Perl script to ... 3- When the validate is okay, the user input will store in the ...
    (comp.lang.perl.misc)