Topic: How to convert masses and volumes ?

I have just completed a cooking recipe management application (MVD 6.6).
I would like to add a mass and volume conversion form (Kg to g, mg... and L to cl, ml into French), but I'm a little confused with the type of variable (double? single?).
I enter in a first Edit1 the mass to be converted (ex. 1 Kg) and via the Form1.Edit1.OnChange instruction, the conversion is available in each of the following EditBoxes.
Do you have an idea to do this? Would calculated fields be okay?
I searched the internet but couldn't find anything conclusive.
Thanks in advance.
J.B.

Re: How to convert masses and volumes ?

To store and process any physical quantities, floating-point numbers (with double precision) are usually used.

I recommend storing data in the database itself in a standardized form, for example, in SI. This will prevent you from getting confused in the calculations.

And for the convenience of the user, provide the ability to recalculate in units convenient for him, both when entering data through the form (scripts), and when displaying in a tabular form (calculated fields).

I don’t have a ready-made recipe for implementation, it all depends on how you see it.

For example, in the database you can store the value itself (in kilograms), and the desired representation (link to the directory of representations - kilogram, gram, pound, etc.).

And in the view directory there are two fields: the name and the coefficient by which the value should be multiplied:
kilogram - 1
grams - 1000
pound - 2.2

You can also store the display precision (number of characters after busy) for a given view.

Then a table display can be done through a calculated field.

Or maybe you do not need to store the desired view for each record in the database, but store it in a global parameter, as a link to the view directory.

Визуальное программирование: блог и телеграм-канал.