Qbasicnews.com
February 26, 2020, 01:09:02 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 2 [3]
  Print  
Author Topic: Odd or even?  (Read 10289 times)
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #30 on: April 09, 2003, 12:11:06 AM »

Wanna make me start again?

/jk
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #31 on: April 10, 2003, 11:14:59 PM »

odd.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #32 on: April 10, 2003, 11:30:52 PM »

.
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
whitetiger0990
__/--\__
*****
Posts: 2964



WWW
« Reply #33 on: April 29, 2003, 11:00:49 PM »

Code:
input x
if x and 1 then print "Odd" else print "Even"

 I dont exactly understand how this works?
Logged


[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Ninkazu
Been there, done that
*****
Posts: 1169



WWW
« Reply #34 on: April 29, 2003, 11:09:54 PM »

That compares the bits of the number, so if the last bit is 0, then it's even.

::EDIT::
Here's an example.
111 (in binary) = 7
111 AND 1 would return true ( 1 ), meaning its last bit is 1.
1000 ( 8 ) AND 1 returns false ( 0 ), meaning its last bit is 0.

::EDIT2::
1110 is 14, not 8.. I'm too freakin tired. Blurg.
Logged

am an asshole. Get used to it.
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #35 on: April 30, 2003, 11:06:40 AM »

100000 times slower than a real AND in assembly.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #36 on: April 30, 2003, 02:16:38 PM »

An AND in Basic is just as "real" as an AND in ASM, and an AND in ASM is just as "non-real" as an AND in Basic.  The underlying mathematical operation's the same.  *That's* the reality.
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #37 on: April 30, 2003, 05:22:04 PM »

an asm and is faster..
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #38 on: April 30, 2003, 05:28:43 PM »

.
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
DrV
Na_th_an
*****
Posts: 1553



WWW
« Reply #39 on: April 30, 2003, 06:28:04 PM »

Ever heard of BASM?  It's a subset of BASIC that actually takes the BASIC code and outputs standard assembly that you can assemble with your assembler and I think I just used the word "assemble" too many times, but... it is BASIC, and yet it is ASM, so there.  Ha.
Logged
toonski84
__/--\__
*****
Posts: 2567



« Reply #40 on: April 30, 2003, 06:28:27 PM »

an "asm and" isnt faster.  the actual operation, having a direct asm equivalent, isnt affected at all.  however, an asm "if" is faster.  though putting going through all the trouble of using qb's stack handler to call an asm routine would most likely make an asm'd odd/even test slower than qb's process.

WHY IS THIS A DISCUSSION TOPIC ANYMORE!! *screams at god*
Logged

i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #41 on: April 30, 2003, 10:15:21 PM »

oh.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Pages: 1 2 [3]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!