Link to home
Start Free TrialLog in
Avatar of jerseyguy0
jerseyguy0

asked on

php

what is example when (($y-1 & 8) == 0) is true
ASKER CERTIFIED SOLUTION
Avatar of swerves
swerves

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jerseyguy0
jerseyguy0

ASKER

does this just say evens and odds
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Given a set of integers $y=1,2,3... the expression is true until you reach 8. When $y is 9, the expression is false. It counts to eight. It more accurately, it returns true for y=1..8, false for 9..16, true for 17..24 and so on.

I want to set it to ten

how could I make it
Given a set of integers $y=1,2,3... the expression is true until you reach 10. When $y is 11, the expression is false. It counts to ten. It more accurately, it returns true for y=1..10, false for 11..20, true for 21..30 and so on.


but I dont think ($y-1 & 10) would work
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
10 is what I need.
10 is the max for y
if you want to test odd or even numbers you can use:



<?php
    echo "\$number is $number and it's " . ( ($number & 1) ? 'odd' : 'even' ).'.';
?>

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial