d3 / d3-interpolate

Interpolate numbers, colors, strings, arrays, objects, whatever!

Home Page:https://d3js.org/d3-interpolate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support BigInt?

Fil opened this issue · comments

  • 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 #74 (comment)).

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

https://observablehq.com/d/a990a01f65d4056f

see also #73.

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.

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

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