Forums / Developer / ezfloat - rounding up number issue

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

eZ debug

Timing: Jan 18 2025 05:21:25
Script start
Timing: Jan 18 2025 05:21:25
Module start 'content'
Timing: Jan 18 2025 05:21:27
Module end 'content'
Timing: Jan 18 2025 05:21:27
Script end

Main resources:

Total runtime1.4418 sec
Peak memory usage4,096.0000 KB
Database Queries191

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0060 587.7188180.8281
Module start 'content' 0.00611.2019 768.5469493.3047
Module end 'content' 1.20800.2338 1,261.8516333.4688
Script end 1.4417  1,595.3203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.2956210.0002
Check MTime0.00170.1148210.0001
Mysql Total
Database connection0.00070.049210.0007
Mysqli_queries1.372895.21151910.0072
Looping result0.00180.12751890.0000
Template Total1.415298.220.7076
Template load0.00190.129820.0009
Template processing1.413398.022120.7066
Template load and register function0.00020.011510.0002
states
state_id_array0.00070.047410.0007
state_identifier_array0.00270.188220.0014
Override
Cache load0.00160.1097220.0001
Sytem overhead
Fetch class attribute can translate value0.00130.088130.0004
Fetch class attribute name0.00100.070320.0005
XML
Image XML parsing0.00040.029230.0001
class_abstraction
Instantiating content class attribute0.00000.000520.0000
General
dbfile0.00330.2280210.0002
String conversion0.00000.000330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 8
 Number of unique templates used: 5

Time used to render debug report: 0.0005 secs