. . .what is the math behind this? . . .
Probability. By computing the probability of winning the various hands and applying that probability to the payoff involved in a win, you can determine the house edge.
and what would you consider perfect strategy?
I should have said perfect Basic Strategy, and not perfect strategy, I apologize for my mistake. Plenty of respected study has already been done into the probabilities and payoffs involved in blackjack. These studies have computed the best possible action for any set of cards under any common set of rules. The strategies that have been calculated from these studies are collectively referred to as "Basic Strategy". Blackjack Basic Strategy changes depending on the rules you are playing under. So, to play "perfect" Basic Strategy is first to know the proper strategy for the particular set of Blackjack rules you are playing under, and then to never make a single decision that differs from the appropriate Basic Strategy.
. . .i went to hitorstand.net and it seemed to help me a lot and i doubled my money at bitzino but it took a long time. i don't think think i have a 99.6% of winning with my strategy.
hitorstand.net will get you started learning some of the more common aspects of Basic Strategy, but it only accounts for 2 sets of blackjack rules, and it allows you to make mistakes on a few hands. For example, at hitorstand if you have a pair of 2 and the dealer is showing a 3, hitorstand doesn't care whether you hit or split in that situation. It will tell you that you are correct either way. At bitzino the proper strategy is to hit. As another example, hitorstand teaches you to always hit when you have an 11 and the dealer is showing an Ace. While this is correct strategy when the dealer stands on soft 17, at bitzino the dealer hits on soft 17 so the proper strategy at bitzino is to double in this situation.
Unless you know exactly which mistakes you are making, it is difficult to know how much extra edge you are giving up to the house. You could try keeping track of exactly how much you are betting, exactly how many hands you are playing, exactly how many hands you've won, and exactly how much you've won on each hand that you won. Then after a thousand or so hands you could try adding up all your bets and all your winnings. Subtract your total winnings from your total bets to get your total loss. Then divide your total loss by your total bets to determine what the house edge is against you.
Note: You do not have a 99.6% chance of winning any individual hand. There will be some hands where you will have a better than 50% chance of winning the hand (such as when you are dealt a 20, and the dealer is showing a 6. There will be some hands there you will have worse than a 50% chance of winning the hand (such as when you are dealt a 16 and the dealer is showing a 10). Overall the average chance of winning a hand of blackjack is less than 50% Fortunately, the rules allow you to put extra money on the table when your chances are better than 50% (through doubling or splitting), and they do better than double your money when you are dealt 21 (if it doesn't pay 3:2, then don't play). This helps shrink the house edge a bit.
Lets say we play a game where you pay a dollar to flip a coin. If it lands on "heads" I give you back your dollar plus an additional dollar of my own. If it lands on "tails" you lose your dollar. Assuming a fair coin that isn't biased toward heads or tail, over a great number of trials it will generally land on heads just about as many times as it lands on tails. You will win as much as you lose and there is no house edge. You only win 50% of the time, but there is no house edge. The house is just as likely to win or lose money as you are, and only statistical variance will determine our "luck".
Now lets modify the game. We use a coin that is slightly weighted so that it comes up tails a bit more often than heads. Lets say that it comes up tails 50.5% of the time. Now after 5000 flips of the coin you will win approximately 2,475 times and lose 2,525 times. The edge is so small you still feel like you are winning approximately 50% of the time, but the "house" now has an edge of 1%. This doesn't mean that you have a 99% chance of winning. It means that the house will keep approximately 1% of the money that you bet over a large number of trials. (You bet $1 per trial and play 5000 trials, you lose on average $50). A bad run of losses could wipe you out early, and a good run of wins could keep you in the game a bit longer, but over a large enough number of trials you lose approximately 1% of the total money bet. In this game, after 5000 trials, you've bet $5000 and won approximately 2475 of them getting $4950 back. Losing $50 per $5000 bet gives a house edge of 1%.
Interestingly, we can get the same effect by keeping the fair coin and modifying the payout. This is why casinos don't need to "cheat" at their games. They can offer perfectly fair dice, perfectly shuffled cards, and a perfectly balanced roulette wheel, and still ensure themselves a win over time by modifying the payout from a "fair" payout. So in our coin game, using a "fair" coin, instead of winning a dollar I give you your bet back along with $0.98 with every win. Now after betting $5000 on 5000 trials you've won approximately 2500 trials. So you've bet $5000 and gotten $4950 back. As we said in the game with the biased coin, losing $50 per $5000 bet gives you a house edge of 1%.
The casino uses fair equipment and adjusts the winning payoff to make sure that they get a profit over a large number of trials. There is no need to "rig" the games, because they've already rigged the outcome by adjusting the payoffs. In any short run, a player here or there will get lucky and their short term statistical variance will be larger than the house edge, meaning that player ends up winning some, but the casino has enough people playing to make up for those losses. With enough money flowing through the casino's games, the house edge overcomes their variance and they come out ahead overall.