formulate Posted February 18, 2022 Posted February 18, 2022 (edited) Created a new float field and it is converting any numbers past the 6th to zero. Example: I enter 123456789 in to the field and after saving the number is 123456000. I have checked and ensured the character limit is set to it's default "10". I also tried "0" and "999". None of that worked. PW version 3.0.184 SOLUTION: use the "Decimal" fieldtype that is built in to the core. It's not installed by default, you need to enable it in Modules > Core. Edited February 18, 2022 by formulate Marking solved.
Robin S Posted February 18, 2022 Posted February 18, 2022 2 hours ago, formulate said: Created a new float field and it is converting any numbers past the 6th to zero. Info here: https://github.com/processwire/processwire-requests/issues/173 You probably want FieldtypeDecimal (was a third-party module, now part of the core) for accurate decimal numbers. 4
MarkE Posted February 18, 2022 Posted February 18, 2022 @formulate: per @ryan (see https://github.com/processwire/processwire-issues/issues/1502), "It's okay to change it to a double directly in the DB schema if you want to. I have done this on the rare occasion when it was helpful and it works just fine." i.e. you can copy and hack the float fieldtype and make it type 'double' - if decimal doesn't fit your need . I'm still not sure why 'double' isn't provided out of the box.
formulate Posted February 18, 2022 Author Posted February 18, 2022 Ok, so this is getting over my head a bit. My numbers are not scientific notation, I just want a way in PW to be able to specify a 7 or 8 digit number, possibly with 2 decimal places and have it not manipulated in any way. I guess I could just use a text field, but that defeats the purpose.
formulate Posted February 18, 2022 Author Posted February 18, 2022 Oh, just figured out there's a "Decimal" fieldtype in the core that isn't installed by default. This looks like it will do the trick. Thanks everyone.
Jan Romero Posted February 18, 2022 Posted February 18, 2022 +1 for installing Decimal by default and perhaps even making Float uninstalled by default. 3
formulate Posted February 18, 2022 Author Posted February 18, 2022 Just now, Jan Romero said: +1 for installing Decimal by default and perhaps even making Float uninstalled by default. Totally agree to this. I imagine most common case-use scenarios would be for using Decimal rather than Float. Given the additional confusion with Float and how the numbers get manipulated (which isn't readily clear anywhere that I could see), it definitely seems like Float should not be the default option that's installed.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now