Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI 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 September 10th, 2004, 05:06 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default MOD function in calculator

I would like to know the Javascript for the MOD function in a calculator.

Let's say I have the constant 22, and x is a variable:

remainder= x MOD 22

So if x is higher than 22, let it divide. The answer I'm looking for is the quotient, the letter R (for remainder) and the remainder.

 
Old September 14th, 2004, 12:03 PM
Registered User
 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

use the % operator like
a = 19 % 4

 
Old September 14th, 2004, 04:18 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

ok thanks

 
Old September 15th, 2004, 03:42 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

how can I make 0 to 22. When the remainder = 0 I want it to say "22"

 
Old September 24th, 2004, 09:25 AM
Registered User
 
Join Date: Sep 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use the mod function but add one to the value.

So if I have a random integer "rand" and I want it's value to be from 0 to 22. The code would be.

val = rand % 23;

This way any value that is divisible by 23 will be 0. So now "val" will only have values from 0 to 22.





Similar Threads
Thread Thread Starter Forum Replies Last Post
ONline Diary Mod Question Mel64081 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 February 8th, 2007 05:18 PM
include param in mod evaluation mlaba XSLT 5 October 20th, 2004 09:40 AM
Chacpter 11 MOD 2old2play BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 4 August 24th, 2004 02:09 PM
Mod 10 for application polj74 VB.NET 2002/2003 Basics 0 July 21st, 2004 07:11 PM
Problem with Mod operator LordBeholder VB How-To 2 June 16th, 2004 06:26 AM





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