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

Fix number interpolator ending value for very large a #63

Closed
wants to merge 1 commit into from

Conversation

yamass
Copy link

@yamass yamass commented Jan 30, 2019

Current situation:

When a number interpolator is applied to a very large floating point number starting value, the ending is 0.

var i = interpolate.interpolateNumber(2e+42, 335);
i(1.0) === 0 // !

This is due to floating point number arithmetic errors:

var a = 2e+42;
var b = 335
var delta = b - a;
delta === -2e+42 // !

Fix

There is IMO no perfect fix for the calculation for 0<t<1,
but for t===1, the ending value should be returned (without any calculation).

@mbostock
Copy link
Member

We should fix this, but we should fix not just interpolateNumber but all the other interpolators at the same time. I’ve filed #73 to track with my proposed formula.

@mbostock
Copy link
Member

Superseded by #76.

@mbostock mbostock closed this Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants