Jump to content


Photo

TNxNumberColumn precision bug?


  • Please log in to reply
1 reply to this topic

#1 LongBeard_Boldy

LongBeard_Boldy
  • Members
  • 11 posts

Posted 17 April 2015 - 10:57 AM

Greetings to Bergsoft comunity,

 

well, today i encountered another bug I think, well ok, am a bad liar. seen something similar a while ago in some other number components too, but did always work a way around it. 

Been lazy and didn't roam around the sources, maybe later will. 

 

I have set to all numeric columns its precision to 2, but on several rows, it does not round. 

 

it happens when i set rows value with maths logic in it like for example from my code: 

 

ng_preces.Cell[ng_preces_bp.Index, i].AsFloat := u_task.FieldByName('sm_p').AsFloat - u_task.FieldByName('sm_n').AsFloat - u_task.FieldByName('sm_i').AsFloat;

u_task is an sql  returned  dataset.

both storage types are Extended, and what's more weird is that values from dataset are already rounded to two digit precision,  so i dont see a reason why  4186,23 - 3466,01 - 23,71 results in 696,509999999

so even if for some reason datasets field values precision floated for +- 0,000000001 as floats sometimes do, why cells display value isnt rounded according to set precision in TNxNumberColumn column properties?

  

 

usually i put maths logic in roundto(), but you know, with age am getting more and more lazy :)

 

 

 

 

 



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,195 posts
  • Gender:Male

Posted 20 April 2015 - 03:25 AM

Hi,

 

It is important to remember that value displayed in cell and actual value inside cell may differ. So I suggest that you do rounding of Cell's value by yourself.


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users