Hello all,
I was wondering if it is possible to create an if statement that does different things depending on how many decimal places appear in a number?
For example if I have the numbers 27.23 and 30.496 can I do an if statement that multiples 27.23 by 4, but multiplies 30.496 by 5?
What I need is a way to do different things to numbers depending on if they have 2 (or less) decimal places, and 3 (or more) decimal places.
Is this possible?
Long Version Context:
For work I handle an Amazon account. Sometimes someone will order something with shipping, gift wrapping, the wrong tax, etc, and our system isn't equipped to handle that, so we have to wrap the costs into the item price. So Product X usually sells for $30, but one order had extra shipping for $2.48, so that 2.48 gets added into the item price. If it was one item, that's easy, 32.48. But if someone buys five for $150, and the shipping is the same 2.48, the item price becomes $152.48 total, but prices have to be entered individually, so divided by five it becomes 30.496 Obviously we can't enter something with three decimals, so what I have to do is enter four at one price, and the fifth at another. 4x30.49 (30.496 rounded down) and 1 at 30.52, so it equals the proper total.
I have to do this 50-100 times. So I'm looking for a way to automate the math with an if statement: Essentially if item price + extra charges / items sold has two (or less) decimal places, just return that number, but if the result has three (or more) decimal places it would do a different function. I can work out the function I needed, just don't know how to set it so it only applies to numbers with three or more decimals.
Thanks,
I was wondering if it is possible to create an if statement that does different things depending on how many decimal places appear in a number?
For example if I have the numbers 27.23 and 30.496 can I do an if statement that multiples 27.23 by 4, but multiplies 30.496 by 5?
What I need is a way to do different things to numbers depending on if they have 2 (or less) decimal places, and 3 (or more) decimal places.
Is this possible?
Long Version Context:
For work I handle an Amazon account. Sometimes someone will order something with shipping, gift wrapping, the wrong tax, etc, and our system isn't equipped to handle that, so we have to wrap the costs into the item price. So Product X usually sells for $30, but one order had extra shipping for $2.48, so that 2.48 gets added into the item price. If it was one item, that's easy, 32.48. But if someone buys five for $150, and the shipping is the same 2.48, the item price becomes $152.48 total, but prices have to be entered individually, so divided by five it becomes 30.496 Obviously we can't enter something with three decimals, so what I have to do is enter four at one price, and the fifth at another. 4x30.49 (30.496 rounded down) and 1 at 30.52, so it equals the proper total.
I have to do this 50-100 times. So I'm looking for a way to automate the math with an if statement: Essentially if item price + extra charges / items sold has two (or less) decimal places, just return that number, but if the result has three (or more) decimal places it would do a different function. I can work out the function I needed, just don't know how to set it so it only applies to numbers with three or more decimals.
Thanks,