Joined: 09 Mar 2012
Online Status: Offline
Posts: 46
Topic: Looking for Number After Decimal Posted: 18 Nov 2021 at 8:14am
We have a field called "Base Price" which in our table is always 4 numbers after the decimal. We want to be able to read the number right after the decimal and based on this reading return either two decimals for the price or 4 decimals.
For example we want to know if the digit right after the decimal is a "0" or not. If it is a "0" then we leave the field alone. So in this case if the field reads "0.0925" we return "0.0925".
If the field reads "1" or any other number up to "9" i.e. not a zero obviously then we want to return only two decimals and also round up the number as well. So for example if the field reads "0.1099" we want to return in this case "0.11".
Simply if it is a "0" immediately to the right of the decimal stays as four digits to the right of the decimal. If 1-9 then round up (if applicable) to only two digits.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum