Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #11  
Old 10-09-2006, 03:15 AM
daltamira daltamira is offline
Senior Member
 
Join Date: Aug 2006
Location: Argentina
Posts: 959
Default RE: Auto rounding.

So strange, I've set the number of decimals in the regional settings to zero and the value 1.956 is rounded to 2.00, if I set the decimals to two, the value is rounded to 1.96, and if I set the decimals to trhee, the value doesn't change and the grid shows me 1.956.
Where is the "CurrencyDecimals" variable? Where do you set this variable from?
Reply With Quote
  #12  
Old 10-09-2006, 03:22 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default RE: Auto rounding.

Delphi has some built-in public variables that override all the "Regional Settings" in the "Control Panel". In other words, if you set the "CurrencyDecimals" variable when the application starts it will never check Windows settings for that. Please search Delphi help for "CurrencyDecimals".

Regards,
Abdulaziz Jasser
Reply With Quote
  #13  
Old 10-09-2006, 04:03 AM
daltamira daltamira is offline
Senior Member
 
Join Date: Aug 2006
Location: Argentina
Posts: 959
Default RE: Auto rounding.

Oh! of course, I know about this public variables, I'm losing my mind :'D
Look, check if before you set CurrencyDecimals, the table was not open, I mean, the table could be open (active=True) at design time or maybe you are opening the table and then set CurrencyDecimals or somehow the table is opened before you can set CurrencyDecimals.
Reply With Quote
  #14  
Old 10-09-2006, 04:19 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default RE: Auto rounding.

Sorry but none of what you said.

Regards,
Abdulaziz Jasser
Reply With Quote
  #15  
Old 10-09-2006, 05:58 AM
Eddy-B Eddy-B is offline
Senior Member
 
Join Date: Feb 2002
Posts: 1,467
Default RE: Auto rounding.

Ok. that is true.
Still you should not set it to 2 decimals, if you want all 3.

Eddy-B

Please click Accept as answer if this helped
Reply With Quote
  #16  
Old 10-09-2006, 06:18 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default RE: Auto rounding.

I don't want the whole 3 decimal digits; all I want is to round the number to two digits when I set decimal variable to 2. This is the way it should be.

1.956 ===> 1.96

Regards,
Abdulaziz Jasser
Reply With Quote
  #17  
Old 10-09-2006, 12:52 PM
BaraoZemo BaraoZemo is offline
Senior Member
 
Join Date: Nov 2001
Posts: 3,598
Default RE: Auto rounding.

in your TTable component (dropped in your form) change this property

"displayformat" = #,###.00


Regards
BaraoZemo

ps, don't forget to click in the button and Accept as Answer if this helped you!
Reply With Quote
  #18  
Old 10-10-2006, 08:18 AM
Eddy-B Eddy-B is offline
Senior Member
 
Join Date: Feb 2002
Posts: 1,467
Default RE: Auto rounding.

I'm wondering what database you're using...this should not be happening.
Still, i would just have an integer field and have your application divide the values by 100.0 to get the correct currency value.

Eddy-B

Please click Accept as answer if this helped
Reply With Quote
  #19  
Old 10-10-2006, 08:45 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default RE: Auto rounding.

I've solved the problem and the problem has nothing to do the database (DBISAM). It was a mistake done by one of the developers in tricky unit. Thanks all for comments. However, if you want to see some tricky number:

1- Create a table with a currency field.
2- Use 1.995 as a value for the currency field.
3- Set the "CurrencyDecimals" variable inside the application to 2.

Now display the field in a DBGrid. You will see "2.00"!!!
It should display 1.99, but because of the nature of rounding it will display 2.00!

Regards,
Abdulaziz Jasser
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 08:42 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.