When looking at consumer electronic devices with batteries I sometimes see the battery capacity listed in Wh (watt hours) and sometimes in mAh (milliamp hours). I would like to be able to compare the two different metrics and I'm wondering how to convert from one value to the other.
The Simple Answer
DC Power is defined in terms of W = 1 V * 1 A - that is, the power that is delivered by sustaining 1V potential with 1A of current.
Thus, a battery pack that can deliver 5400mAh, that is 5.4Ah, while sustaining voltage of 10.4V (this happens to be running in my laptop right now), can in theory deliver up to 5.4 * 10.4 = 56.16 Wh = 56160mWh.
The Complicated Answer
The above get a lot more complicated with different battery chemistries, and with different measurement methods. Firstly, the mAh rating can depend on the actual current draw - in general, the more current you draw, the less capacity the battery has, but there are exceptions at both ends of this guideline (if you draw too slowly, self discharge affects your measurement, and if you drive quickly enough, the battery gets warmer, and if it doesn't break, it tends to perform better).
Also, the voltage across the battery changes with the load - this is at least simple, the more current you draw, the lower the voltage across the terminals (this is due to internal resistance).
Finally, some devices are essentially dumb loads (battery powered tools), and draw as much as they can from the battery.. and some devices handle voltage and current changes in a more intelligent manner (mostly laptops and other DC/DC converters).
This means that for dumb loads, you are more concerned with mAh ratings (perhaps measured until battery voltage remains above some usable threshold).. since this can be used to calculate time-to-empty (which is really what you or your users are after), and dumb loads are approximately constant current/constant resistance loads.
For smart loads, the discharge controller (DC/DC converter) would actually try to drain constant power - the lower the voltage, the more current it drains so that it can continue outputting constant power on it's business end.
Simply put, Wh, or Watt-hours, is the measure of *voltage * Amp-hours*.
In the case of the batteries you're looking at, you typically see mAh as the quoted battery capacity figure. So, for example, a typical AA Ni-MH rechargable battery has a nominal cell voltage of 1.2V. If you find one with a capacity of 2,000mAh, it would have a 2.4Wh rating.
If you want to take a Wh rating and convert it to mAh, divide it by the voltage of the battery and multiply that by 1000. For example: A 90Wh battery that has a voltage of 12V. Divide 90 by 12, which gives you 7.5. Multiply by 1000, and you now have the mAh rating of 7,500mAh.