In PHP, I have a 64 bit number that is necessary to complete the task. A second 64 bit number represents tasks that have been completed:
$ pack_code = 100111110010000000000000001111110100111110010000000000000001011111 $ veri_code = 0000000000000000000000000000011100000000000000000100000000000000000000000000000000111110 I have two comparisons To perform and provide one percent of the tasks, the whole figure could loop through both, and found how many bits are set, but I do not know it is the fastest way?
Assuming that these are actually strings, maybe something like this:
$ pack_code = '1001111100100000000000000011111101001111100100000000000000011111'; $ Veri_code = '00000000000000000000000000011100000000000000000000000000000000111110'; $ Matches = array_intersect_assoc (str_split ($ pack_code), str_split ($ veri_code)); $ End_matches = array_intersect ($ matches, array (1)); $ Percent = (count ($ end_match) / 64) * 100
Comments
Post a Comment