aspjson
aspjson copied to clipboard
Overflow: 'Clng Line 240
Line 240 reads: val = Clng(Replace(val, ".", ""))
when val = 50.16093600000001
Apparently 14 decimal places wasn't expected in your code, but sometimes it is necessary (Latitudes and Longitudes may need extreme precision and that is what I am working with).
I noticed you are using CLNG. The maximum allowed value is 2,147,483,647 (10 digits). I understand that while coding sometimes I tend to go with the quick and dirty just to get the job done. I'm actually going through my code I built using your library but now I need my Latitudes and Longitudes to be a bit more accurate than 10 digits so I'll be changing the function aj_ReadNumericValue
to read as:
Private Function aj_ReadNumericValue(ByVal val) If Instr(val, ".") > 0 Then ''< duh val = trim(val) if len(val) > 15 Then val = left(val,15) 'Limiter required in order to avoid breaking the DOUBLE data type numdecimals = Len(val) - Instr(val, ".") val = CDBL(Replace(val, ".", "")) val = val / (10 ^ numdecimals) aj_ReadNumericValue = val Else aj_ReadNumericValue = CDBL(val) End If End Function
Just an FYI. Thanks for the code! Works really well (once I trim my 14 decimal places down).
You can use a simplest way.
Private Function aj_ReadNumericValue(ByVal val)
aj_ReadNumericValue = val + 0
End Function
You can use a simplest way.
Private Function aj_ReadNumericValue(ByVal val) aj_ReadNumericValue = val + 0 End Function
Not sure how that doesn't break it even more.
Hi, i had the same problèm but with big numeber, i use CDbl instead of CLng to resolve my problem. It was hard to find because no error occurs but when overflow comming the code just stop parsing the json without raise any error
By the way, thank for the code