473,386 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Checking to see if a number is 'natural'

23
I am creating an application that has to check for natural numbers. By natural numbers, I mean positive whole numbers.


Expand|Select|Wrap|Line Numbers
  1. //natural needs to equal 1,2,3, etc.
  2. if(minutes % 60 == natural) {
  3. minuteField.value = minutes;
  4. }

How can I can I do this? Thanks.
Sep 6 '07 #1
3 4305
pbmods
5,821 Expert 4TB
Heya, Anon. Welcome to TSDN!

Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).

Try this instead:
Expand|Select|Wrap|Line Numbers
  1. function isNatural( val )
  2. {
  3.     return ( (val > 0) && (Math.floor(val) == val) );
  4. }
  5.  
  6. if( isNatural(minutes % 60) )
  7. {
  8.     ...
  9. }
  10.  
Sep 6 '07 #2
anon538
23
Thanks, it worked perfectly. I'm not sure what was wrong with my thread title, but nonetheless, I really appreciate your help.
Sep 6 '07 #3
pbmods
5,821 Expert 4TB
Heya, Anon.

I don't remember, either. Ah well.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Sep 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

84
by: Andy Glew | last post by:
I am in search of any rigourous, scientific, academic or industrial studies comparing naming conventions in C++ or similar languages such as Ada: Specifically, are names formed with...
7
by: William L. Bahn | last post by:
I recently challenged one of my students to figure out a way to determine if fgets() actually received the entire contents of the input string. When he was having trouble figuring it out even after...
4
by: sathyashrayan | last post by:
(This is not a home work question) Dear group, I want a program to find one number between a set of natural number.A program to guess a number in between a Natural number set.This should be a...
4
by: Patient Guy | last post by:
Does anyone have any coding rules they follow when doing argument checking? When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw...
28
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
1
by: halcyon943 | last post by:
have 4 folders that I watch and need to move files from to another location. Three constraints: -Finish time. Make sure the program stops transferring files at a specific time -Number of...
42
by: =?Utf-8?B?UGxheWE=?= | last post by:
I have an if statement that isn't working correctly and I was wondering how I check for a blank string. My Code Example if me.fieldname(arrayIndex) = "" then ----- end if When I do this and...
63
by: deepak | last post by:
Hi, Can someone give the standard function which can create positive integer value in C? Thanks, Deepak
10
by: Brent | last post by:
I have a list of company names (say, IBM, Corning, General Motors, and another 5,000 of them). If I take a body of text, a news article, for instance, and I want to see which company names...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.