You are not logged in or registered. Please login or register to use the full functionality of this board...
SIGN IN Join Our Community For FREE


Odd & Even Numbers Question ?
05-21-2017, 03:59 PM
Post: #21
 (Print Post)
RE: Odd & Even Numbers Question ?
bplus for Me as you know I always think outside the Box! hence the Success of My A.R.B Chess System...up against all Odds I have shown Modern Chess engine's weaknesses! Smile 

And so it goes with other things like this Odd & Even Number problem...

So 12.356 = Even  156.966 = Even  1234568.9877 = Odd 

For Me I wanted to find a way where Numbers have either an Odd or Even (End Number!) and it's Not exactly about if they are True Odd or Even Numbers it's the last (End Number!) that is important!

I am Not able to exactly say Why! I need such a thing but a small example would be...

If 12.35#  Ends with an Even Number then ??? 
If 12.35#  Ends with an Odd Number then ??? 

So now you can see I have made a Logic Branch using those Numbers which would Not be possible in another way!


Anthony.
Find all posts by this user
Like Post
The following 1 user Likes Anthony.R.Brown's post:
bplus
05-21-2017, 04:29 PM (This post was last modified: 05-21-2017 04:47 PM by bplus.)
Post: #22
 (Print Post)
RE: Odd & Even Numbers Question ?
Quote:
For Me I wanted to find a way where Numbers have either an Odd or Even (End Number!) and it's Not exactly about if they are True Odd or Even Numbers it's the last (End Number!) that is important!

OHHHHHHH, that's easy (or should be)

in SmallBASIC it's this:
Code Snippet: [Select]
dbl = 12.35
? lastDigitOorE(dbl)
pause
func lastDigitOorE(myFloater)
 lastDigitOorE = iff(right(str(myFloater), 1) mod 2, "Odd", "Even")
end


Translate to QB64
Code Snippet: [Select]
'lastDigitOorE.bas for Anthony 2017-05-21


dbl# = 12.35
PRINT lastDigitOorE$(dbl#)


FUNCTION lastDigitOorE$ (d#)
s$ = STR$(d#)
last$ = RIGHT$(s$, 1)
IF (VAL(last$) MOD 2) THEN lastDigitOorE$ = "ODD" ELSE lastDigitOorE$ = "EVEN"
END FUNCTION

B += _
Find all posts by this user
Like Post
The following 1 user Likes bplus's post:
Anthony.R.Brown
05-21-2017, 04:37 PM
Post: #23
 (Print Post)
RE: Odd & Even Numbers Question ?
bplus you may have missed it ? 

figosdev's Solution...
 (below) looks like it works! regardless of whether a Person wants it for the Odd & Even Number problem ? or just the Last Number Problem ? 


function arb_float_oddeven(N)

P = n str right 1 val mod 2
IFTRUE P
P = "ODD" return p
ELSE
P= "EVEN" return p
FIG



Anthony.
Find all posts by this user
Like Post
05-21-2017, 04:55 PM
Post: #24
 (Print Post)
RE: Odd & Even Numbers Question ?
Code Snippet: [Select]
'lastDigitOorE.bas for Anthony 2017-05-21


dbl# = 12.35
PRINT lastDigitOorE$(dbl#)


FUNCTION lastDigitOorE$ (d#)
s$ = STR$(d#)
last$ = RIGHT$(s$, 1)
IF (VAL(last$) MOD 2) THEN lastDigitOorE$ = "ODD" ELSE lastDigitOorE$ = "EVEN"
END FUNCTION

Cool bplus Cool Looks like I now have Two Solutions to the problem! Wink


Anthony.
Find all posts by this user
Like Post
05-21-2017, 04:59 PM
Post: #25
 (Print Post)
RE: Odd & Even Numbers Question ?
Quote:
bplus you may have missed it ?
Yes! It seems I did, time for my nap. ;-))

B += _
Find all posts by this user
Like Post



Forum Jump:


User(s) browsing this thread: 1 Guest(s)




QB64 Member Project - Red Scrolling LED Sign
QB64 Member Project - Dreamy Clock
QB64 Member Project - Kobolts Monopoly
QB64 Member Project - Sabotage
QB64 Member Project - Foursight
QB64 Member Project - Blokus
QB64 Member Project - Dakapo
QB64 Member Project - Full Color LED Sign
QB64 Member Project - Martin Fractals version four
QB64 Member Project - Pivot version two
QB64 Member Project - Algeria Weather
QB64 Member Project - Martin Fractals version two
QB64 Member Project - Bowditch curve
QB64 Member Project - Overboard
QB64 Member Project - Kings Valley verion one
QB64 Member Project - Input
QB64 Member Project - Spinning Color Wheel
QB64 Member Project - Martin Fractals version one
QB64 Member Project - OpenGL Triangles
QB64 Member Project - Martin Fractals version three
QB64 Member Project - Basic Dithering
QB64 Member Project - Othello
QB64 Member Project - Color Triangles
QB64 Member Project - Isolation
QB64 Member Project - ARB Checkers
QB64 Member Project - Pivet version one
QB64 Member Project - MAPTRIANGLE
QB64 Member Project - Touche
QB64 Member Project - Rubix's Magic
QB64 Member Project - Domain
QB64 Member Project - Amazon
QB64 Member Project - Rotating Background
QB64 Member Project - Quarto
QB64 Member Project - Splatter
QB64 Member Project - STxAxTIC 3D World
QB64 Member Project - RGB Color Wheel
QB64 Member Project - 9 Board
QB64 Member Project - Inside Moves
QB64 Member Project - Point Blank
QB64 Member Project - Line Thickness
QB64 Member Project - Connect Four
QB64 Member Project - Exit
QB64 Member Project - Score 4
QB64 Member Project - Kings Court
QB64 Member Project - Qubic
QB64 Member Project - Color Rotating Text
QB64 Member Project - Kings Vallery version two
QB64 Member Project - Swirl
QB64 Member Project - Spiro Roses