If under 1TB in size simply calculate: (Advertised size in GB) * 0.931
Or, to be exact: (Advertised size in GB * 10^9)/1024^3 should do the trick…
Over one TB you can not just assume 1TB = 1,024GB since the advertising calculation is in base 10, and this crazy device in front of you prefers base 2… So:
Over 1TB calculate: (Advertised size in TB) * 0.909
Once again, to be precise: (Advertised size in TB * 10^12)/1024^4.