Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve parseNumber() with Long number #10

Open
GoogleCodeExporter opened this issue May 3, 2016 · 1 comment
Open

improve parseNumber() with Long number #10

GoogleCodeExporter opened this issue May 3, 2016 · 1 comment

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
  1. Set json = lib.parse("{"BigNumber":32769}")
  2. an Exception was raise because the CInt Cannot process the Big number 

What is the expected output? What do you see instead?

  Debug.Assert json.Item("BigNumber") = 32769

What version of the product are you using? On what operating system?


Please provide any additional information below.

'I use CLng to replace CInt
Private Function parseNumber(ByRef str As String, ByRef index As Long)

    Dim value   As String
    Dim char    As String

    Call skipChar(str, index)
    Do While index > 0 And index <= Len(str)
        char = Mid(str, index, 1)
        If InStr("+-0123456789.eE", char) Then
            value = value & char
            index = index + 1
        Else
            If InStr(value, ".") Or InStr(value, "e") Or InStr(value, "E") 
Then
                parseNumber = CDbl(value)
            Else
                parseNumber = CLng(value) 'CInt(value)
            End If
            Exit Function
        End If
    Loop


End Function

Original issue reported on code.google.com by [email protected] on 9 May 2010 at 1:34

@GoogleCodeExporter
Copy link
Author

This needs CDbl instead of CInt. Otherwise you can get numbers which are 
written as a single number but are too big for long. (because it's not written 
using scientific format, the check for "e" or "E" won't pick it up).

Original comment by [email protected] on 27 Aug 2012 at 10:05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant