Any way to work with 3 decimal places internally and show rounded 2 decimal places?

Thread began 3/11/2010 5:18 am by jernej | Last modified 3/11/2010 12:03 pm by jernej | 1471 views | 4 replies |

3/11/2010 5:18 am  |  #1 jernej

Any way to work with 3 decimal places internally and show rounded 2 decimal places?

I have a problem. As I am adding some rules and each rule is rounding to 2 decimal places 8I have set 2 decimals in ecart) after added the values are not the same as if I would add both numbers (as they are a 3 decimal values) and round that to 2 decimals.

If i set 3 decimal places everything is ok except in eCart 4.5.2 shopping cart everything is on 3 places. What I need is that internal calculations would be done using 3 decimal places and the result would then be in shopping cart rounded to 2 decimal places, then the values would be correct.

is that possible, even with a "hack" in the code?

ASP here :-)

Jernej

3/11/2010 11:41 am  |  #2 Jason ByrnesWebAssist

you can use the ASP round() function.

the round function takes 2 arguments, the number to round and number of decimal places.

in the context of displaying an eCart price:

`<%=WA_eCart_DisplayMoney(BlueSkyMusic, WA_eCart_DisplayInfo(BlueSkyMusic, "Price"))%>`

using the round function would look like:

`<%=WA_eCart_DisplayMoney(BlueSkyMusic, round(WA_eCart_DisplayInfo(BlueSkyMusic, "Price"), 2))%>`

3/11/2010 11:46 am  |  #3 jernej

Yes I know I can use round, but then I have to change every money display I drop from binding. I have changed the function Display money and entered 2 as the decimals and used 3 as a global parameter. It works, until I reload GUI then obviously the change dissapear.

Btw: Is round with 2 decimals same as FormatNumber?

3/11/2010 12:00 pm  |  #4 Jason ByrnesWebAssist

There is no way of doing this globally except altering the display money function, but yes, if you edit eCart, you will have to re edit the format number function.

Format number is used to format the display of the number, it will force the number of decimals you tell it to display. This comes into play with round round numbers like 11. if you tell format number to use 2 decimals, it form at 11 as "11.00", whereas round(11, 2) will only return "11". Format number will perform the rounding function though.

3/11/2010 12:03 pm  |  #5 jernej

Thanx for the explanation. Out tax rule is 0.085 (8.5%) and I am allways having a hard time to round things. On some occasions I miss 1 cent :-( Because 0.085 is on 3 decimals and we have to show store output in 2 decimals there comes to rounding errors all the time.

Thank you again.

3/11/2010 12:14 pm  |  #6 Eric Mittman

This post has been deleted.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Everything else!

Close Window

Account or customer service questions?

Need technical support?

Content

Layout

Ease of use

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Window

We were unable to retrieve the attached file

Close Window

Attach and remove files

• Text Formatting
• Insert Element
• Block Formatting
• Cancel
Close Window

Close Window

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --