Wrox Programmer Forums Math problem... help please!
 |
 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

September 30th, 2004, 04:08 AM
 Varg_88 Friend of Wrox Join Date: May 2004 Posts: 105 Thanks: 0 Thanked 0 Times in 0 Posts

Hello guyz...

After a sum function I have the following results.

years = 5
months = 33

Of course the logical function is:
months = 33 -> (24) + 9 = 9
years = 5 + (2) = 7

So, I have to divide months with number <12> but I don`t know how to keep the interger part of the result without "round-ing" and how to get the rest of the division.

I hope that I`m understood! :)

Vagelis!

September 30th, 2004, 04:22 AM
 Varg_88 Friend of Wrox Join Date: May 2004 Posts: 105 Thanks: 0 Thanked 0 Times in 0 Posts

OK. I found the solution!
----------
years = 5
months = 33
i_months = months \ 12
years = years + i_months
j_months = i_months * 12
months = months - j_months
response.write "<td>Years: "&years&" AND months "&months&"</td>"
-----------

Once again I feel so stupid that I couldn`t find this solution with my first try! :(

September 30th, 2004, 05:17 AM
 ChrisScott Friend of Wrox Join Date: Jul 2003 Posts: 683 Thanks: 0 Thanked 1 Time in 1 Post

Hi Vagelis,

I know you've solved the problem, but this may be of use for the future...
Code:
```years = 5
months = 33
years = years + months \ 12
months = months Mod 12
response.write "<td>Years: " & years & " AND months " & months & "</td>"```
HTH,

Chris

 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 question dparsons ASP.NET 1.0 and 1.1 Professional 5 June 14th, 2006 02:31 PM javascript math problem austinf Javascript 1 June 13th, 2006 05:36 AM Math Namespace transtar C# 3 February 12th, 2006 09:50 AM Math problem solved in Java! freezotic BOOK: Beginning Java 2 7 January 21st, 2004 03:40 PM