Most people give a fair amount of thought to buying an appliance or an electronic device. But a warranty for them gets barely any consideration.

If you do buy one, it will probably be out of emotion, fear or because the salesperson wore you down. And you’ll probably be wasting your money. But warranties aren’t hard to understand, and with a little grade school math, you can figure out the rare instances when it makes sense to get one.

A warranty is, after all, a bet, like any form of insurance. For a small price you are betting that something bad will happen that would cost you a lot of money. The other side of the bet is counting on the long life of your product. The company selling the warranty has the information on failure rates. You don’t. So all you need to know are the odds that your product will fail.

That’s not easy to find out. Companies aren’t in the habit of telling you that their products fail 4 percent or 12 percent of the time. Failure rates are usually low. Warranty companies know that. And they know, too, that consumers tend to think the failure rate is higher and that many of those consumers, being risk-averse, will buy the warranty.