processwire / processwire-requests

ProcessWire feature requests.
40 stars 0 forks source link

Guidelines for FieldtypeFloat #173

Open Toutouwai opened 6 years ago

Toutouwai commented 6 years ago

Short description of the enhancement

Please add some explanation and guidelines around the limitations of FieldtypeFloat in the field config descriptions. The limitations of the float field in PW are known and have been investigated and discussed years ago in this forum topic.

Users may not be familiar with the limitations of floating point numbers in PHP/MySQL, and this config field...

2018-03-26_153654

...can lead to confusion. There isn't enough explanation that:

  1. The maximum number of potential decimal places is 6 (the config field should not accept a value higher than this).
  2. The decimal place accuracy also depends on the number of digits before the decimal. So the decimal accuracy of 12345.6789 is really 1 decimal place.

Also, big +1 for this request to add a decimal fieldtype to the core, as for many needs a decimal type would be more appropriate, more intuitive and less confusing than a float type.

LostKobrakai commented 6 years ago

…more intuitive and less confusing than a float type.

This one totally depends on the use-case and knowledge level of the user, but having both float and decimal is certainly not the wrong way to go. At least informing the users about the differences and link to the decimal module. In the end we have a lot of users without in depth knowledge of the complexities behind float / decimal calculation and we might want to prevent uninformed decisions by those users. Lot's of them still probably don't need decimals and their additional complexities in handling them in php.

Jehfen commented 5 years ago

Even better, add decimal to the core, it's a very common data type when working with numbers. Heck, almost all other SQL data types are supported. Even if float has PHP or database limitations, I don't want to be bothered with this when working with a CMS. It's an annoyance to discover floats have precision issues when working with large numbers, but since I'm not a mathematician, I just want it to work. As a comparison, you wouldn't like a text field that didn't save spaces, or omitted every 7th character.

If it's in the core, you can still change the field type later on (to integer, float, text or decimal) when you edit a numeric field, without the need of creating a new field and copying existing page data to it.

adrianbj commented 5 years ago

If it's in the core, you can still change the field type later on (to integer, float, text or decimal) when you edit a numeric field, without the need of creating a new field and copying existing page data to it.

In case you come across this scenario, you can make use of the Admin Tools panel in Tracy to change the fieldtype from float to decimal. image

I am not suggesting this is the right approach, but there has been no word from Ryan about incorporating a decimal fieldtype into the core, so this can help out in a pinch. Of course there are other ways to change the type (API, database modification), but this makes it easy.

matjazpotocnik commented 3 years ago

Decimal filedtype is now in the core https://github.com/processwire/processwire/commit/3603cdb7441b940b2c520c942789cd48ceeca518