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

Support BigInt? #75

Closed
Fil opened this issue Nov 19, 2019 · 4 comments
Closed

Support BigInt? #75

Fil opened this issue Nov 19, 2019 · 4 comments

Comments

@Fil
Copy link
Member

Fil commented Nov 19, 2019

  • d3.interpolate(BigInt(5), BigInt(15))(0.5) throws a TypeError: Cannot convert a BigInt value to a number

  • BigInt64Array and BigUint64Array (typed arrays) could be supported too (see Interpolate typed array folded #74 (comment)).

@Fil
Copy link
Member Author

Fil commented Nov 19, 2019

t === 1 ? B : A + BigInt(Math.round(t * Number(B - A))) seems to be working

https://observablehq.com/d/a990a01f65d4056f

see also #73.

@mbostock mbostock changed the title support for BigInt? Support BigInt? Nov 19, 2019
@mbostock
Copy link
Member

I don’t think we can support BigInt yet—it’s still missing from Safari on both desktop and iOS.

https://caniuse.com/#feat=bigint

Also, it’s a little pointless to interpolate BigInts since you’re necessarily losing the arbitrary precision that BigInt gives you by converting to floats. If you want to interpolate BigInts, it probably makes more sense to convert to a Float64Array (or number) first.

@Fil
Copy link
Member Author

Fil commented Nov 19, 2019

Yes. Exception is when you want the exact values at t=0 and t=1. Anyway it was a nice exercise :)

@Fil Fil closed this as completed Nov 19, 2019
@mbostock
Copy link
Member

We should fix the exact values at t={0,1} per #73 independent of the type.

Fil added a commit that referenced this issue Nov 19, 2019
- interpolates typed arrays (Float64Array, etc) and standard arrays that contain only numbers with a simple for… loop.
- autodetects both situations (we could optionally unplug the number array detection)
- not compatible with BigInt typed arrays (#75)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants