Anthony Posted August 10, 2016 Posted August 10, 2016 I am using a custom function to format a number into currency format ( two decimals ). RoundDecimals(11.0) = 11.00 The problems occurs when I use a variable: $amount = 11.0 RoundDecimals($amount) = 11.11 Similarly, I get the same error using a string: RoundDecimals("11.0") = 11.11 Is there any tricks to get around this issue ? This is the custom function that I used (I replaced the comma for a dot and defaulted second parameter to 2): https://www.briandunning.com/cf/974
comment Posted August 10, 2016 Posted August 10, 2016 You should not copy and paste code from people you don't know and use it without understanding how it works. Especially when those people don't understand it either. Have a look at (for example):http://fmforums.com/topic/73165-how-can-i-add-trailing-zeros-100-need-1000/#comment-437360
jbante Posted August 10, 2016 Posted August 10, 2016 (edited) 18 minutes ago, comment said: You should not copy and paste code from people you don't know and use it without understanding how it works. Needing to understand how it works would defeat half the value of using someone else's code. Encapsulation is a beautiful thing. Edited August 10, 2016 by jbante
Anthony Posted August 10, 2016 Author Posted August 10, 2016 I agree with jbante. But of course, we have to make sure the source is reliable. 20 minutes ago, comment said: Have a look at (for example):http://fmforums.com/topic/73165-how-can-i-add-trailing-zeros-100-need-1000/#comment-437360 Thanks, this is much simpler and works like a charm !
Recommended Posts
This topic is 3279 days old. Please don't post here. Open a new topic instead.
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