Page 1 of 1

even numbers and odd numbers

PostPosted: Tue Mar 15, 2022 9:23 am
by Silvio.Falconi
is there a function to check if a number is even or odd?
thanks

Re: even numbers and odd numbers

PostPosted: Tue Mar 15, 2022 9:42 am
by nageswaragunupudi
Code: Select all  Expand view

function IsEvenNumber( n )
return ( ( n % 2 ) == 0 )
 

Re: even numbers and odd numbers

PostPosted: Tue Mar 15, 2022 10:33 am
by Silvio.Falconi
nageswaragunupudi wrote:
Code: Select all  Expand view

function IsEvenNumber( n )
return ( ( n % 2 ) == 0 )
 


thanks

Re: even numbers and odd numbers

PostPosted: Tue Mar 15, 2022 2:33 pm
by AntoninoP
As old school programmer
Code: Select all  Expand view
function IsEvenNumber( n )
return ( hb_bitand(n,1)  == 0 )