testing value of last digit of an integer.
delta trinity
deltatrinity at hotmail.com
Sun Apr 4 23:25:18 CEST 2004
you could use mpz_divisible_p
It is much faster than doing a complete division.
>From: David McKen <cic_3_b at yahoo.com>
>Reply-To: cic_3_b at yahoo.com
>To: "Mailing List, GMP" <gmp-discuss at swox.com>
>Subject: testing value of last digit of an integer.
>Date: Sat, 3 Apr 2004 21:23:08 -0800 (PST)
>
>I want to check if the last digit of an integer is 5.
>
>I am contemplating using the mpz_tstbit function to test for the
>binary
>representation of 5 which is 0 1 0 1. The leading zero is to prevent
>13 from
>accidentally being detected. Any further out and the binary digits
>would not
>affect the last digit.
>
>Does anyone know any other way I can do this?
>
>The numbers are quite large (about 300 digits) and it is already
>known that
>the numbers are odd.
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! Small Business $15K Web Design Giveaway
>http://promotions.yahoo.com/design_giveaway/
>_______________________________________________
>gmp-discuss mailing list
>gmp-discuss at swox.com
>https://gmplib.org/mailman/listinfo/gmp-discuss
_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee®
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
More information about the gmp-discuss
mailing list