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

Evaluate bigInt usage #4110

Open
olegbespalov opened this issue Dec 10, 2024 · 0 comments
Open

Evaluate bigInt usage #4110

olegbespalov opened this issue Dec 10, 2024 · 0 comments
Labels
area: browser evaluation needed proposal needs to be validated or tested before fully implementing it in k6

Comments

@olegbespalov
Copy link
Contributor

olegbespalov commented Dec 10, 2024

What?

Currently, we do parse bigInt as regular integers

case runtime.TypeBigint:
n, err := strconv.ParseInt(strings.ReplaceAll(val, "n", ""), 10, 64)
if err != nil {
return nil, BigIntParseError{err}
}
return n, nil

Which could not work if we face a really big number, like:

package main

import (
	"fmt"
	"math/big"
	"strconv"
	"strings"
)

func main() {
	// A large number string
	bigIntString := "123456789012345678901234567890"

	bigInt := new(big.Int)
	_, success := bigInt.SetString(bigIntString, 10) // Base 10

	if !success {
		fmt.Println("Failed to parse big integer")
		return
	}
	fmt.Println("Parsed big.Int:", bigInt)

	n, err := strconv.ParseInt(strings.ReplaceAll(bigIntString, "n", ""), 10, 64)
	if err != nil {
		fmt.Println("Failed to parse int64 " + err.Error())
		return
	}

	fmt.Println("Parsed N:", n)
}

So probably we should use the bigInt type there if possible 🤷

Why?

Actual support of bigInt

@olegbespalov olegbespalov transferred this issue from grafana/xk6-browser Dec 13, 2024
@olegbespalov olegbespalov added evaluation needed proposal needs to be validated or tested before fully implementing it in k6 area: browser labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: browser evaluation needed proposal needs to be validated or tested before fully implementing it in k6
Projects
None yet
Development

No branches or pull requests

1 participant