Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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 June 12th, 2006, 07:12 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default Math question

Greetings all,
   I am working on an application and need to know at the end of code execution if an integer value is a multiple of 10 or not and if it isnt, round up to the next number that is a multiple of 10. I am thinking I need to use Mod for this but am not sure how I would go about checking this, any help would be greatly appreciated! thanks!

"The one language all programmers understand is profanity."
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old June 12th, 2006, 07:34 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 331
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to qazi_nomi
Default

Dear take the number and devide it into 10 then you would get the number in float check the number after decimal point if it is less than 5 then multiply the integer portion with 10 other wise add 1 to integer part and multiply to 10 it will give you the round to 10
eg you have the number 113 at the end. So devide it to 10 tha answer would be 11.3 check the number after decimal point which is 3 so less than 5 so no need to add 1 to 11 but multiply 11 by 10 which gives 110 which is ur round to 10. One more example you got 78 at the end so devide it on 10 which will got 7.8 so the number after decimal point is 8 so add one number to 7 which become 8 now multiply it by 10 which will become 80 it is ur answer.
Hopefully you got the answer

(*_*)

Numan
--------------------------------------------------
It is not important what you get But important is how you got it
 
Old June 12th, 2006, 03:48 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

If <YourValue> Mod 10 = 0 Then
.. do something
End if

 
Old June 12th, 2006, 08:02 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

I think this will work fine:

<%
    Dim theRem as integer
    Dim theInt as integer
    Dim theNewInt as integer
    theInt = 79
    theRem = theInt Mod 10
    theNewInt = theInt + (10 - theRem)
    Response.Write("This is the good integer: " & theNewInt)
%>

Set your variable value to the value of your test integer.

 
Old June 14th, 2006, 08:27 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ahh thats the beautiful thing about programming so many different ways to do the same thing. =] Thanks everyone.

"The one language all programmers understand is profanity."
 
Old June 14th, 2006, 02:31 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

I have a simple mind so usually my solutions are ... uh... pretty simple.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with Math.pow trryan5 Java Basics 4 July 27th, 2007 06:12 AM
Math operators nguyendh BOOK: Ivor Horton's Beginning Visual C++ 2005 1 June 25th, 2006 01:35 AM
Math functions-Please help! jroxit ASP.NET 2.0 Basics 5 December 28th, 2005 12:21 PM
math.floor casper BOOK: Beginning Java 2 1 October 29th, 2004 11:24 AM
Math on a Form kelcontech Classic ASP Basics 4 May 12th, 2004 05:01 PM





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