Go Back   Sportbike Addicts | Two Wheels... Our Drug of Choice > Miscellaneous > Off Topic
FAQ Members List Member Gallery Calendar Today's Posts Donate
Reply
 
Thread Tools Display Modes

Need Help : coders help a brother out
Old 04-03-2006, 08:59 PM   #1
soda7o
Lazy Ass
 
soda7o's Avatar
 
soda7o is offline
Join Date: Jun 2005
Location: Brooklyn
Posts: 2,242
Send a message via AIM to soda7o
Default Need Help : coders help a brother out

OK this is kind of simple but i need help....

i need to write function lets call it F the function can be passed a number Lets sa any umber form 1 to 2 billion
1 it needs to check if it is an int (1 2 3 or 1.5 if it si a fraction no go)
2 the function has to reurn either true or false if the number is a multiple of 2 example if i say 8 2X2X2 = 8 the fun will return true
if i say 4 2X2 the func will return true
if i pass i 3 it should return false.
also 10 it shodul return false..


help a brother out...

thanks

C++ or java

thanks agian in advance
__________________
  Reply With Quote

Old 04-03-2006, 09:14 PM   #2
Gear Dog
Tank Slapper
 
Gear Dog's Avatar
 
Gear Dog is offline
Join Date: Jul 2005
Location: Newburgh, NY
Posts: 390
Send a message via AIM to Gear Dog
Default

Try Ctrl Alt Del
__________________
  Reply With Quote

Old 04-03-2006, 09:41 PM   #3
jcblitz
Having Troubles w/His Wood
 
jcblitz's Avatar
 
jcblitz is offline
Join Date: May 2005
Location: Yesterday
Posts: 1,608
Default

If you can define the rule mathamatically, I'll write the code for you. And in java, there aren't "numbers", it's got to be a type. IE: int, float, double...so by design the method will only accept whole numbers.
__________________


Knowledge is free. We are Anonymous. We are Legion. We do not forgive. We do not forget. Expect us.

Minarchism
  Reply With Quote

Old 04-03-2006, 11:16 PM   #4
jcblitz
Having Troubles w/His Wood
 
jcblitz's Avatar
 
jcblitz is offline
Join Date: May 2005
Location: Yesterday
Posts: 1,608
Default

Well I wrote some code and checked 10000 results, only printing the trues. If this works, I'll paste the code for you.

The check of 2 is true
The check of 4 is true
The check of 8 is true
The check of 16 is true
The check of 32 is true
The check of 64 is true
The check of 128 is true
The check of 256 is true
The check of 512 is true
The check of 1024 is true
The check of 2048 is true
The check of 4096 is true
The check of 8192 is true
__________________


Knowledge is free. We are Anonymous. We are Legion. We do not forgive. We do not forget. Expect us.

Minarchism
  Reply With Quote

Old 04-04-2006, 01:11 AM   #5
soda7o
Lazy Ass
 
soda7o's Avatar
 
soda7o is offline
Join Date: Jun 2005
Location: Brooklyn
Posts: 2,242
Send a message via AIM to soda7o
Default

Quote:
Originally Posted by jcblitz
Well I wrote some code and checked 10000 results, only printing the trues. If this works, I'll paste the code for you.

The check of 2 is true
The check of 4 is true
The check of 8 is true
The check of 16 is true
The check of 32 is true
The check of 64 is true
The check of 128 is true
The check of 256 is true
The check of 512 is true
The check of 1024 is true
The check of 2048 is true
The check of 4096 is true
The check of 8192 is true

paste te code please

oh eah it would be an int
__________________
  Reply With Quote

Old 04-04-2006, 02:43 AM   #6
jcblitz
Having Troubles w/His Wood
 
jcblitz's Avatar
 
jcblitz is offline
Join Date: May 2005
Location: Yesterday
Posts: 1,608
Default

Just an FYI, the max value an int can be in Java is 2^31-1

code:
Code:
       private static boolean isMultipleOfTwo(int value){
		float total = value;
		while (total > 1) {
			total/=2;
		}
		
		if (total == 1) {
			return true;
		} else {
			return false;
		}
	}
__________________


Knowledge is free. We are Anonymous. We are Legion. We do not forgive. We do not forget. Expect us.

Minarchism
  Reply With Quote

Old 04-04-2006, 09:19 AM   #7
soda7o
Lazy Ass
 
soda7o's Avatar
 
soda7o is offline
Join Date: Jun 2005
Location: Brooklyn
Posts: 2,242
Send a message via AIM to soda7o
Default

Thanks jc but i think its not what i needed close
i worked onit my self an got soething like this


public function { int number }
( returns String )
{

multipleOfTwo = "False";

for ( i=1; i=31; i++ )
{
if ( 2^i != int number )
{
continue;
}
else
{
multipleOfTwo = "True";
break;
}
}
return (multipleOfTwo);
}
__________________
  Reply With Quote

Old 04-05-2006, 10:23 AM   #8
sonny
Craigslist Champion
 
sonny is offline
Join Date: Mar 2006
Posts: 893
Default

nerds
  Reply With Quote

Old 04-05-2006, 11:30 AM   #9
soda7o
Lazy Ass
 
soda7o's Avatar
 
soda7o is offline
Join Date: Jun 2005
Location: Brooklyn
Posts: 2,242
Send a message via AIM to soda7o
Default

Quote:
Originally Posted by sonny
nerds

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
__________________
  Reply With Quote

Old 04-06-2006, 11:12 AM   #10
CuCullin
MCSE
 
CuCullin's Avatar
 
CuCullin is offline
Join Date: May 2005
Posts: 460
Default

*EDIT: Bah. Helps to read all of the thread.
  Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -4. The time now is 04:16 AM.
 

vBulletin skin developed by: eXtremepixels
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.