Re: Datatype checking in DotNET



Nicholas Sherlock wrote:
Daniel Hobson wrote:
Yeah I am doing that now at the moment for example as based on the given
example previously:-

I use StrToFloat, if this fails, it raises an exception (Which is fine of
course).

But what I am trying to achieve here is to ensure the data integrity, does the data meet the float bounds?????

StrToFloat will almost certainly do that too. Give it a try with a really big float, something like 10E1000.

The StrToFloat function ultimately calls System.Double.TryParse(String,NumberStyles,IFormatProvider,out Double) to do the conversion.

Assigning a Double to a Single will throw an ArithmeticException if the result is not finite.

--
Rob
.



Relevant Pages

  • Re: Datatype checking in DotNET
    ... You can use a function called StrToFloat ... But what I am trying to achieve here is to ensure the data integrity, does the data meet the float bounds????? ... (IntImSavingToo)) ...
    (comp.lang.pascal.delphi.misc)
  • Re: FPU Control World
    ... I have never, yet, found a problem with Delphi's StrToFloat. ... "float" storage and calculations. ...
    (borland.public.delphi.language.basm)
  • Re: Datatype checking in DotNET
    ... Yeah I am doing that now at the moment for example as based on the given ... But what I am trying to achieve here is to ensure the data integrity, ... StrToFloat will almost certainly do that too. ... Give it a try with a really big float, ...
    (comp.lang.pascal.delphi.misc)
  • Re: Region settings
    ... >using Strtofloat and floattostr make the app crashing. ... StrToFloat uses the regional setting for DecimalSeparator selected by ... This will avoid raising an exception (assuming S is otherwise a well ...
    (borland.public.delphi.language.objectpascal)