Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 13th, 2003, 09:44 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Rounding

hi i have a tricky problem
i am trying to round some numbers
but i want to round them up

eg..
if i had 1.1 i want it to round to 2
if i have 1.9 i want it to round to 2 again
if i have 1.0 i want it to round to 1

i have used Round() but it rounds 1.1 to 1
i have used Fix() + 1 but it rounds 1.0 to 2

the only way i can think of doing this is with a heap of complicated if statements and i dont want it to come to that

thanks for any help :)
 
Old August 14th, 2003, 12:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I don't know of any inbuilt function but youe could use something like
Code:
function roundUp(num)
    dim arrNum, leftover
    arrNum = split(cstr(num),".")
    roundUp = arrNum(0)
    leftover = num - roundUp
    if leftover > 0 then roundUp = roundUp + 1
end function


======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old August 14th, 2003, 03:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:if i had 1.1 i want it to round to 2
if i have 1.9 i want it to round to 2 again
if i have 1.0 i want it to round to 1
How about
Code:
x = IIf(n - Fix(n) > 0, Fix(n + 1), n)
where n is the number to be rounded and x is the result.
 
Old August 14th, 2003, 08:45 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you both





Similar Threads
Thread Thread Starter Forum Replies Last Post
Rounding problem rajanikrishna Classic ASP Basics 1 August 17th, 2006 12:14 AM
Rounding JasperGIS Beginning VB 6 1 December 14th, 2005 03:09 PM
Rounding kilika SQL Server 2000 4 June 1st, 2005 03:36 PM
What's with the rounding?? kaizer BOOK: Beginning Java 2 2 December 22nd, 2003 11:36 PM
Rounding in C# cjo ASP.NET 1.0 and 1.1 Basics 3 November 3rd, 2003 04:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.