Rounding Errors and formatting

I am having real problems with Servoy 3.5.rc6/MySQL and formatting of numbers:

Specifically:

Number entered = 18.35

Format #.## = Number is rounded to 18

Format #.00 = number is rounded to 18 and shown as 18.00

No formatting - number is rounded to 18

I am completely frustrated and lost as to what to set to get numbers formatted to two decimal places and no rounding applied.

ANy ideas you be very gratefully received!

Cheers

What datatype does the dataprovider (table column) have?

#.## would be ok.

Have you checked if the datatype of your field in the database isn’t integer?

Hi Gordon,

Change the datatype of the dataprovider to Number and set the default format to ‘#.##’, it will solve your problem.

Hope it will help. :wink:

ROCLASI:
What datatype does the dataprovider (table column) have?

I used Servoy to define a number column and initially left the formatted it as #.00. On inspection in Navicat I believe Servoy set this as a decimal - however the length and decimals were left blank therefore it defaulted to rounding the decimals and simply inserting .00 after each number.

When I set the length and decimals in Navicat the problem was resolved - I did however imagine that this would have been set-able in Servoy as part of the column definition.

Thanks very much for your response

Regards

ars:
Hi Gordon,

Change the datatype of the dataprovider to Number and set the default format to ‘#.##’, it will solve your problem.

Hope it will help. :wink:

I did this repeatedly and tried re setting the number format in Navicat to Float, Decimal, Numeric etc and re tried the solution with no effect. The problem was resolved by setting the length and number of decimals in Navicat.

I did think it seemed counter productive to need to intervene with another application on a field definition as simple as Numbers - I will try this process again in a blank file and make sure I am not doing something wrong - I generally use Navicat to define the db structure rather than Servoy so its possible.

Thanks for the reply

Joas:
#.## would be ok.

Have you checked if the datatype of your field in the database isn’t integer?

Yep its a number and I tried deleting and re creating some of them as an experiment - no dice :( #.## resulted in 18.35 being displayed as 18 and that was what was stored in the back end db.

The problem was resolved by setting length/decimals in Navicat

Thanks for your reply