Too many decimal places

Brentnauer - August 3, 2009 - 20:59
Project:Views Calc
Version:6.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Perhaps I'm missing something, but it seems we need a way to define how many decimals places to show when averaging something out. Right now I'm averaging something and it's giving me 0.222222222222222. This is obnoxious and takes up a lot of room.

Isn't there a way to limit it to two decimal places?

#1

Brentnauer - August 12, 2009 - 19:42

Am I the only one having this issue? If it's something I'm overlooking I'd appreciate someone telling me so :P Driving me crazy for weeks now.

#2

Brentnauer - September 4, 2009 - 06:32

Bump.

Anybody?

#3

Brentnauer - October 8, 2009 - 15:11

Is anyone else even having this issue? What am I doing wrong? I've been looking for months now...

#4

davedg629 - October 18, 2009 - 00:00

Yea, for my averages I am getting 4 decimal places (e.g 1.5321)

#5

davedg629 - October 18, 2009 - 17:18

Copy the view-calc-table.tpl.php file (found in the views_calc module folder) to your theme folder. Clear your cache (by going to admin/settings/performance and hitting the "clear cache" button). Your theme will now recognize this new template file.

You can now use the round() function to round the results down using the following code:

<td class="view-footer views-field views-field-<?php print $fields[$field]; ?>  <?php print $options['info'][$field]['justification'] ?>">
  <?php print round($content, 2); ?>
</td>

This will round all of the calculations to the nearest 100th (1.00). Lookup the round() php function on google to learn more about how to use it, its pretty easy (e.g. round($content, 0) will round 1.5432 to 2).

#6

Brentnauer - October 21, 2009 - 16:34
Status:active» closed

You are AMAZING. Thank you :)

 
 

Drupal is a registered trademark of Dries Buytaert.