Skip to content

Conversation

@amorsent
Copy link

@amorsent amorsent commented Sep 8, 2020

Issue #662692 by joachim, hanoii, ShaneOnABike, lunazoid, 5t4rdu5t: strange decimal precision error on floating numeric fields.

Cherry-picked: https://git.drupalcode.org/project/views/commit/8d86ce2

Essentially in views_handler_field_numeric, if you don't set precision you can get weird floating point issues.

…trange decimal precision error on floating numeric fields.
@amorsent
Copy link
Author

amorsent commented Sep 8, 2020

Note: This is the commit that went into Views 7.x-3.x and is how it is to this day.
It is worth noting, though this fixes the floating point issue, it retains any trailing 0's in the decimal. eg: 99.00800

I discovered a different fix went into Views in core:
Issue #1952926 NumericField.php does not support negative value rendering in range -0.xx.
Commit

That issue is apparently solving a different issue, but also fixes this one. Instead of cutting and pasting the decimal component it is determining the precision and then rounding. This also avoids the trailing 0's issue....

I can roll an alternate pull request using that fix if you like - but presumably it should go into 7.x-3.x first?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants