ezfloat - rounding up number issue

Author Message

steve walker

Friday 27 July 2007 6:35:53 am

Hi there,

We have an issue with ezfloat in conjunction the l10n operator. It seems its covered to an extent here:

http://issues.ez.no/3755

However, I havent been abl to fix our issue - which is that we are storing financial figures in a system - and when the numbers start going over 1,000,000 the number start getting rounded to the nearest 100. The full operator is:

|l10n(number)

How can I change the operator so that it just displays the exact number without any rounding, preferably with 2 decimal places?

Many thanks, Steve.

http://www.oneworldmarket.co.uk

Felipe Jaramillo

Wednesday 01 August 2007 10:15:03 am

Hi Steve,

We have now reproduced, investigated and solved the rounding issue. It is related to the default mysql database structure, where numbers (float) are 4 bytes and rounded after 6 figures by default.

We have successfully changed this to allow 15 figure numbers before rounding them. After doing the change in our test servers, it does not disrupt the existing data.

In my opinion, people should be warned about this inaccuracy as it affects any default installation and there is no alternative datatype for accurately storing long numbers other than TextLine.

This inaccuracy is present in the existing numbers 6 figure numbers and up as they are rounded. Eg. 1234567 is stored as 1234570.

To fix:

Increase length of FLOAT to 25 (8 bytes) in “data_float” field in table “ezcontentobject_attribute”, which will effectively make it a DOUBLE 8byte number, accurate to 15 figure numbers.

More info in:
http://dev.mysql.com/doc/refman/4.1/en/choosing-types.html
http://dev.mysql.com/doc/refman/4.1/en/storage-requirements.html
http://dev.mysql.com/doc/refman/4.1/en/numeric-types.html

Felipe Jaramillo
eZ Certified Extension Developer
http://www.aplyca.com | Bogotá, Colombia

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:44:37
Script start
Timing: Jan 18 2025 11:44:37
Module start 'layout'
Timing: Jan 18 2025 11:44:37
Module start 'content'
Timing: Jan 18 2025 11:44:38
Module end 'content'
Timing: Jan 18 2025 11:44:38
Script end

Main resources:

Total runtime1.0626 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 587.9219152.6250
Module start 'layout' 0.00630.0044 740.546939.4453
Module start 'content' 0.01071.0504 779.9922488.2266
Module end 'content' 1.06110.0014 1,268.21888.1563
Script end 1.0625  1,276.3750 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3123160.0002
Check MTime0.00140.1329160.0001
Mysql Total
Database connection0.00070.062210.0007
Mysqli_queries1.019295.9167540.0189
Looping result0.00050.0497520.0000
Template Total1.028696.820.5143
Template load0.00210.196220.0010
Template processing1.026596.602420.5132
Template load and register function0.00020.016310.0002
states
state_id_array0.00090.082310.0009
state_identifier_array0.00130.118620.0006
Override
Cache load0.00170.1572220.0001
Sytem overhead
Fetch class attribute can translate value0.00060.058820.0003
Fetch class attribute name0.00100.092920.0005
XML
Image XML parsing0.00020.023420.0001
class_abstraction
Instantiating content class attribute0.00000.000620.0000
General
dbfile0.00070.0683100.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 8
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs