Numeric and non numeric data


  • I am reading a data file and storing them in an array of string.
    Data is random, could be like "1","2","133,18" but sometimes there can be missing values like "?".
    Once I load the data in the array, I want to check if at least a majority (like 60% of them) are numeric values.
    If yes, then I wanna track down the higher and lowest value in the array, and output a range of 5.

    Loop through the array
        If 60% of them are numbers (integers or decimals) then
            find highest value, find lowest value
        end if
    produce range

    If for example lowest = 1 and highest = 100, range of 5 means 0,20,40,60,80,100 (so 5 ranges are 0-20, 20-40, 40-60, 60-80, 80-100).
    Also if the ranges turn to have decimals due to weird numbers, I would like to round them up.

    My problem is, in order to find highest and lowest when there are non numeric values in the array like "?", how should I handle those? I was thinking of something like Double.NaN but I would have to have an array of doubles.

    Any suggestions on the logic to be followed? Not asking about code just need to find some efficient/optimized solution on this one.

    Best regards
    -Knock knock -Who's there? -(looong pause..) Java
    Friday, January 22, 2010 6:43 AM


All replies

  • I would start using the Visual Basic function IsNumeric(......................)

    Friday, January 22, 2010 7:38 AM
  • Yup but if IsNumeric(array(i)) = false then shouldn't it give it a numeric value?
    -Knock knock -Who's there? -(looong pause..) Java
    Friday, January 22, 2010 7:40 AM
  • No then you go to another method, like CDbl(, CInt( etc. While as it contains non numeric characters you can try Val(

    Visual Basic has a bunch of those methods (those are not in C#) but full framework methods.

    They are better described for version 2010 than in previous version so I give you that link
    • Marked as answer by s0m30n3x Friday, January 22, 2010 8:08 AM
    Friday, January 22, 2010 7:50 AM