This is the worst situation,but it is allowed. The fallow is what i want to do

---------------------------------------------------------------------------------------

/// <summary>

/// Performs the rounding.

/// Truncates everything past the accuracy digit, and rounds the last digit

/// down.

/// </summary>

/// <exception>FormatException if number is not a valid floating-point

number</exception>

/// <exception>ArgumentNullException if number is null</exception>

/// <exception>ArgumentException if comparisonDigit is less than 1 or

greater than 9</exception>

/// <param name="number">the number to round</param>

/// <param name="accuracyDigit">the desired accuracy</param>

/// <param name="comparisonDigit">the comparison digit</param>

/// <returns>the rounded number</returns>

public override string Round(string number, int accuracyDigit, int

comparisonDigit)

{

try

{

Double db = Double.Parse(number);

}

catch (FormatException fe)

{

throw new ConfigurationException("The given number is invalid.");

}

catch (OverflowException ofe)

{

if (number.IndexOf("e") >= 0 &&number.Substring(number.IndexOf("."),

number.IndexOf("e")).Length < accuracyDigit) // unfinishted

{

}

}

int index = number.IndexOf(".");

string str = number.Substring(0, index + accuracyDigit);

if (accuracyDigit == 0)

{

return number.StartsWith("-") ? Convert.ToString((Convert.ToInt32(str) -

1)) : str;

}

else

{

return number.StartsWith("-") ?

str + Convert.ToString((Convert.ToInt32(number[index + accuracyDigit])

-47)) :

number.Substring(0, index + accuracyDigit + 1) ;

}

}

------------------------------------------------------------------------

"Jon Skeet [C# MVP]" wrote:

"Anders Nor?s [MCAD]" <an**********@objectware.no> wrote: Thanx very much.

It is helpful to me.But it still cannot solve my problem.Because (0.1e1234

or 0.12e-450 or -.12345664544544 or

654564,4654,14.22222221432545414145515454464646) all the above string is

allow input and they are valid . So according to ur advice, i can call

Double.prase(..) to check the given string contain invalid char or not,if it

throws FormatException, the given string is invalid, if it throws

OverOfException, it is allowed, and i should parse it by other way(but the

format is correct just over the flow i think) .

Decimal is the largest floating point type in the .NET framework. You

should use Decimal if you're handling large numbers.

Decimal is certainly the largest in terms of number of bits, but it

doesn't handle the largest numbers.

Decimal.MaxValue is 79,228,162,514,264,337,593,543,950,335.

Double.MaxValue is 1.79769313486232e308 - considerably larger.

--

Jon Skeet - <sk***@pobox.com>

http://www.pobox.com/~skeet

If replying to the group, please do not mail me too