Closed (outdated)
Project:
Radioactivity
Version:
6.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
17 Jul 2010 at 00:00 UTC
Updated:
26 Jan 2018 at 13:52 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
nancydruI am not much into Views handler code, so I have to leave this one to others.
Comment #2
Katrina B commentedSubscribing.
I came up with a workaround in Views by using the "Trim this field to a maximum length" option and setting the maximum length to 6. But that doesn't actually round; it just cuts off the number at a certain point. So I have numbers like 101.59 and 86.593. The ability to specify rounding for these numbers, so they all end with the same number of decimal places, would be really nice.
Comment #3
nancydruAlgebraically, one of 101.59 and 86.593 is incorrect as it has an inconsistent number of significant digits, as would 6.92626288147332. So yes, we need a consistent formatting of decimal places.
Comment #4
Katrina B commentedWhich is why I refer to it as a "workaround" and not an actual solution. Believe me, I want to see proper rounding as much as you do.
Comment #5
nancydruUh, oh, Earl might think I'm learning a little.
Change the field: 'handler' => 'views_handler_field_numeric'
Add 'float' => TRUE to the field, something like
Now clear the Views cache. Then edit the view and the field. Voila!
Comment #6
nancydruHere's a patch.
Comment #7
Katrina B commentedOkay, now that it's a number ... how do I round it off to a certain number of decimal places?
Comment #8
nancydruNow that's really weird! When I was doing this, another checkbox for rounding showed up above the 1000's separator, but it's not there now.
Comment #9
nancydruI had tried several combinations and apparently missed one cache clearing.
Comment #10
Katrina B commentedIt works! I'm delighted. Thanks so much.
Comment #11
Druid commented(re: #3)
101.59 and 86.593 do have the same number of significant digits (5). Where they differ is in the number of decimal digits (after the decimal point). PHP allows formatting of real numbers (floats) with a given length and number of decimal digits, but I don't think it has a built-in way to get a fixed number of significant digits. If that's what you want, you'd have to examine the number first to see how many digits are before the decimal point (roughly, 1 + floor(log |x|)), and figure your number of decimal digits from there, on the fly.
How many significant digits to show is a whole art and science in itself, starting with the number of significant digits available in your original data, and all conversion factors used in-between.
Comment #12
nancydruYou are correct, I meant significant decimal digits. The patch fixes the problem. If someone else will test it, please mark it as RTBC.
Comment #13
nancydruHas no one tested this? It's a pretty simple patch, perhaps it can be committed without the RTBC. I'm about to need this again and would like to not have to patch it right off the bat.
Comment #14
meason commentedJust thought I'd let you know, the patch worked for me. I manually did the patch on my version, 6.x-1.3 and it worked like a charm. Thank you :-)
Comment #15
sutharsan commentedIssue triage: Closing issue, the 6.x branch is no longer maintained.
If you believe this issue is closed in error, feel free to re-open.