Consider an example Pokémon, like Pikachu with this set of IVs:
025.png Hit Points Attack Defense Speed Sp.Attack Sp.Defense
30 31 31 31 30 31
Hidden Power's type of a Pokémon with given IVs is represented by a number, calculated with this formula:
>where a,b,c,d,e,f (the "type bits") are the least significant bit of their respective IV's. If a number is odd, its least significant bit is 1, and it is 0 otherwise.
a depends on the HP IV.
b and c depend on the Attack and Defense IV's respectively.
d depends on the Speed IV.
e and f depend on the Special Attack and Special Defense IV's respectively.
This simply means that every element of the sum in the brace is the remainder of division of corresponding IV and 2, multiplied by appropriate power of 2 (20 in case of a and 25 in case of f). The sum may range from 0 (when all IVs are even) to 63 (when all IVs are odd), inclusive. It is worth mentioning that the computed sum may be easily calculated by putting its variables a,b,c,d,e,f together in reverse order and interpreting this as a number in the binary system, which then needs to be reverted to decimal system:
fedcba(2) = 32f+16e+8d+4c+2b+a (10)
The summed value is then multiplied by 15 and divided by 63, to be sure that the number representing Hidden Power Type will range from 0 to 15, inclusively (16 values in total). The calculated number is then rounded down (floor), which simply means that only integral part of the calculated number is considered.
The resulting number will correspond to a type as marked below.
In our example, we get:
Hit Points Attack Defense Speed Sp.Attack Sp.Defense
HP Type = Floor[(0 + 2 + 4 + 8 + 0 + 32)*15/63] = Floor[46*15/63] = Floor[10.952] = 10, which means that our Pikachu has a Grass-type Hidden Power.
So, no a Dark-Type HP does not mean you have perfect IVs