Format for aligning floating numbers to the point

Hi All

I would like to align in fields floating numbers to the decimal point but can’t find an appropriate format. Like in a text app the decimal tab. I seem to be unable to find a decimal alignment cmd or format.

Example:

734.743
63.34
690.5

Thanks for any hint.

Best regards, Robert

Hi Robert,

look at the horizontal aligment property when you have selected a field.
Hope this helps

Hi Harjo

Thanks for the hint, unfortunatly there is also in the horizontal alignment no selection for something like decimal, i. e. adjusting to a decimal point, only left, center, …

Or do you mean something else?

Regards, Robert

HJK:
Hi Robert,

look at the horizontal aligment property when you have selected a field.
Hope this helps

ah, now I see your point!
no, no function right out the box in Servoy.

You could calc it yourself, but that is definitly a brain-braker! :-)

HJK:
… but that is definitly a brain-braker! :-)

Nah, you just need a fixed-width font and some padded spaces. Easy. :)

But knowing Robert I don’t think he wants workarounds ;)

What about adding a format like #.000 to the field and right align?

Hi Robert

ROCLASI:

HJK:
… but that is definitly a brain-braker! :-)

Nah, you just need a fixed-width font and some padded spaces. Easy. :)

Yeahh, easy, but as you already guessed I don’t like the work around with fixed font, as this looks … (aehhh unaestethically .-)

ROCLASI:
But knowing Robert I don’t think he wants workarounds ;)

I can’t say it better than you .-)

Thanks a lot and regards, Robert

Hi Nicola

This would be the solution under “normal” circumstances. I forgot to explicitly mention that I still have to see my data as they are in the database (also for the reason to sometimes correct them)

If I apply the format #.000

then my data

734.743
63.34
690.5

looks like this

734.743
63.340
690.500

and I cannot differentiate if the value in the database is 690.5 (reality in this example) or 690.500 which is unfortunatly not good.

I actually thought the format ###.### would do the job but doesn’t. Has anyone an idea why a format “decimal” like center, right, … doesn’t exist?

Best regards and thanks, Robert

ngervasi:
What about adding a format like #.000 to the field and right align?

Robert Huber:
and I cannot differentiate if the value in the database is 690.5 (reality in this example) or 690.500 which is unfortunatly not good.What about adding a format like #.000 to the field and right align?

I’m not understanding: what’s the difference between 690.5 and 690.500? How can your database store different data?
Or do you mean that you store these values as strings in a text field?

Hi Nicola

Between the 690.5 and 690.500 is matematically no difference, but I can visually see on the 690.5 number that it is actuall missing 2 digits, i. e. it should be 690.5xx but isn’t (at the moment). The numbers are actually longitudes and latitudes from the Swiss Grid (CH1903) for maps. As soon as I see 690.500 I am not sure if the two zeros are for real or added by the format number and that’s the problem: the format adds something to the number I can not differentiate (visually) any more, so I am not sure if the real number in the database is 690.5 or really 690.500.

Hope my explanations give a little bit a clearer view why I am searching for such a strange thing at first glance.

Regards, Robert

ngervasi:

Robert Huber:
and I cannot differentiate if the value in the database is 690.5 (reality in this example) or 690.500 which is unfortunatly not good.What about adding a format like #.000 to the field and right align?

I’m not understanding: what’s the difference between 690.5 and 690.500? How can your database store different data?
Or do you mean that you store these values as strings in a text field?

Robert Huber:
Hi Nicola

Between the 690.5 and 690.500 is matematically no difference, but I can visually see on the 690.5 number that it is actuall missing 2 digits, i. e. it should be 690.5xx but isn’t (at the moment). The numbers are actually longitudes and latitudes from the Swiss Grid (CH1903) for maps. As soon as I see 690.500 I am not sure if the two zeros are for real or added by the format number and that’s the problem: the format adds something to the number I can not differentiate (visually) any more, so I am not sure if the real number in the database is 690.5 or really 690.500.

I don’t know which database and what type of column are you using but when you ask a database to store let’s say a DECIMAL(10,3) it will always store 3 digits after the dot whenever you are writing 1,2 or 3 digits while inserting the value. A number is a number no matter what.
Unless you are storing your values in a text column or in a FLOAT column (very different story…) and I don’t think this is the case.

So the value in the database is always the same, you can choose how to format it in servoy and even if you want to enforce the user to use your format when inserting data in it.

Hi Nicola

Yes, of course the values are floating point numbers and stored as such in the database, see my picure, look at Breite (Latitude), Laenge (Longitude) and Delta Distance values.

Regards, Robert

ngervasi:

Robert Huber:
Hi Nicola

Between the 690.5 and 690.500 is matematically no difference, but I can visually see on the 690.5 number that it is actuall missing 2 digits, i. e. it should be 690.5xx but isn’t (at the moment). The numbers are actually longitudes and latitudes from the Swiss Grid (CH1903) for maps. As soon as I see 690.500 I am not sure if the two zeros are for real or added by the format number and that’s the problem: the format adds something to the number I can not differentiate (visually) any more, so I am not sure if the real number in the database is 690.5 or really 690.500.

I don’t know which database and what type of column are you using but when you ask a database to store let’s say a DECIMAL(10,3) it will always store 3 digits after the dot whenever you are writing 1,2 or 3 digits while inserting the value. A number is a number no matter what.
Unless you are storing your values in a text column or in a FLOAT column (very different story…) and I don’t think this is the case.

So the value in the database is always the same, you can choose how to format it in servoy and even if you want to enforce the user to use your format when inserting data in it.

There’s no picture attached, maybe it wasn’t uploaded properly. Can you repost it?
I don’t think using FLOATs is a good idea but maybe I’m missing something here…

Hi Nicola

I have attached the picture now :-)

Regards, Robert

ngervasi:
There’s no picture attached, maybe it wasn’t uploaded properly. Can you repost it?
I don’t think using FLOATs is a good idea but maybe I’m missing something here…