0

I am using datatable.compute where the formula is stored in xml file retrieved dynamically.Now i am getting error as Cannot interpret token '.' at position 5 in asp.net, all are decimal and i dont know why i am getting this error for FORMULA=(0.7.0*1000.0*30.0*115.0)/(1000.0)

decimal dec= ((decimal)(dt.Compute(FORMULA, ""))).Normalize();


public static class Extensionclass
{
    public static decimal Normalize(this decimal value)
    {
        return value / 1.000000000000000000000000000000000m;
    }
} 

2 Answers 2

2

The first part of the formula (0.7.0) is not a valid decimal.

7
  • What do i have to do here ,since everything is coming from databace.What would be the generic solution since i am doing complex calcluation contain big numbers
    – peter
    Sep 27, 2018 at 8:08
  • 2
    @peter What do you mean? Your data in the database is wrong. Sep 27, 2018 at 8:10
  • 1
    @peter That depends on what 0.7.0 should be. We can´t tell you what that "number" should mean. If that was insrted by user-control, I suppose you have a low validation for the input, which won´t check such errors. Sep 27, 2018 at 8:12
  • That is entered by user by using another aplplication.so i cannot control it rather adjusting from my side ,i changed to float, but not working
    – peter
    Sep 27, 2018 at 8:12
  • 2
    @peter Does 0.7.0 mean something? You'll need to write code to convert it to a form that lets you convert it to a float, if that's the correct thing to do. If it doesn't mean anything, then I'd throw that data out as bad because it's not a number. Sep 27, 2018 at 8:13
0

some how i managed like if value less than 1,first i will multiply by 10 and then finally after datatable.compute, for those whose value less than 1 again i will divide by 10,thanks all

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.