[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
Solved

# Rounding results of a division to 2 decimal places

Posted on 2004-09-09
Medium Priority
217 Views
Rounding results of a division to 2 decimal places

I have the following lines of code in the body section of a web page which is displaying data from a database using the DateBase Results Wizard:-

<%
varDisplayAcres = fp_rs("plotarea")
varDisplayAcres = varDisplayAcres/4047
%>

I am wanting to display a plot area of land which is on an Access database in square metres, also as acres.  This involves dividing by 4047 as a good enough approximation.  I need the results to be displayed to only 2 decimal places

Here is an example of what I am having displayed at the moment:-

Plot area (sq.m.) = 590.   Acres = approx 0.145787002718063

I want the acres to be shown as 0.15 for preference, although simple truncation to 3 decimal places, i.e. as 0.145 would be acceptable.

This is I am sure simple, but I am without any textbooks/manuals where I am working at the moment.

(I know how to do this using an Access query with the calculation and the acres embedded within the Access query, but in this case I want to do the calculation outside of Access, and within the displaying web page).

Thanks for assistance.
0
Question by:Jeeva
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2
• 2

LVL 12

Accepted Solution

rcmb earned 400 total points
ID: 12020477

<%
varDisplayAcres = fp_rs("plotarea")
varDisplayAcres = varDisplayAcres/4047
varDisplayAcres = formatnumber(varDisplayAcres,2)
%>

where ,2 gives you the number of decimal places to show.

RCMB
0

Author Comment

ID: 12021289
Thanks very much rcmb for prompt reponse!  Jeeva
0

LVL 12

Expert Comment

ID: 12023570
You are welcome -- just as a side note you should be able to shorten this whole process by entering this:

<%= formatnumber((fp_rs("plotarea")/4047),2)%>

RCMB
0

Author Comment

ID: 12027213
Yes, that's much neater.  Thanks again.   Jeeva
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
###### Suggested Courses
Course of the Month13 days, 11 hours left to enroll