--HcAYCG3uE/tztfnV
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

jzakiya:

> Just a quick tip for you.

> To check for (odd/even)ness:

> Instead of doing this: if (c % 2 !=3D 0)
> which uses the modulo operator '%' which is
> "expensive" in terms of cpu cycles, because it
> performs (with a direct implementation) a (hardware)
> division operation, do this instead:

> # To check if integer c is even (true)
> if (c & 1 =3D=3D 0)

> # To check if integer c is odd (true)
> if (c & 1 =3D=3D 1)

Better yet, use
if c.even?
or
if c.even?
(which are both more readable and do the above binary checks in C).

=E2=80=94 Shot
--=20
To find a rhyme for silver,
A seemingly rhymeless rhyme,
Requires only will, ver-
bosity and time.
           [Willard R. Espy]

--HcAYCG3uE/tztfnV
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkstQUMACgkQi/mCfdEo8UoVBwCgmw8eOjvdfhJLmhYxMGgB3EZh
hGEAoKlroserjxPo06mPJzEHZjkfIje7
=5Ezn
-----END PGP SIGNATURE-----

--HcAYCG3uE/tztfnV--

jzakiya:

> Just a quick tip for you.

> To check for (odd/even)ness:

> Instead of doing this: if (c % 2 != 0)
> which uses the modulo operator '%' which is
> "expensive" in terms of cpu cycles, because it
> performs (with a direct implementation) a (hardware)
> division operation, do this instead:

> # To check if integer c is even (true)
> if (c & 1 == 0)

> # To check if integer c is odd (true)
> if (c & 1 == 1)

Better yet, use
if c.even?
or
if c.even?
(which are both more readable and do the above binary checks in C).

 Shot
-- 
To find a rhyme for silver,
A seemingly rhymeless rhyme,
Requires only will, ver-
bosity and time.
           [Willard R. Espy]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkstQUMACgkQi/mCfdEo8UoVBwCgmw8eOjvdfhJLmhYxMGgB3EZh
hGEAoKlroserjxPo06mPJzEHZjkfIje7
=5Ezn
-----END PGP SIGNATURE-----