{"action":"created","issue":{"url":"https://api.github.com/repos/hgrecco/pint/issues/306","labels_url":"https://api.github.com/repos/hgrecco/pint/issues/306/labels{/name}","comments_url":"https://api.github.com/repos/hgrecco/pint/issues/306/comments","events_url":"https://api.github.com/repos/hgrecco/pint/issues/306/events","html_url":"https://github.com/hgrecco/pint/issues/306","id":120108095,"number":306,"title":"Precision loss using prefixes","user":{"login":"dmwelch","id":961773,"avatar_url":"https://avatars.githubusercontent.com/u/961773?v=3","gravatar_id":"","url":"https://api.github.com/users/dmwelch","html_url":"https://github.com/dmwelch","followers_url":"https://api.github.com/users/dmwelch/followers","following_url":"https://api.github.com/users/dmwelch/following{/other_user}","gists_url":"https://api.github.com/users/dmwelch/gists{/gist_id}","starred_url":"https://api.github.com/users/dmwelch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmwelch/subscriptions","organizations_url":"https://api.github.com/users/dmwelch/orgs","repos_url":"https://api.github.com/users/dmwelch/repos","events_url":"https://api.github.com/users/dmwelch/events{/privacy}","received_events_url":"https://api.github.com/users/dmwelch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-03T07:07:05Z","updated_at":"2015-12-09T17:30:40Z","closed_at":null,"body":"When converting meters to nanometers:\r\n```python\r\n>>> import pint\r\n>>> x = 1.0 * pint.UnitRegistry().meter\r\n>>> x.ito('nm')\r\n>>> x.magnitude == 10.0**9  # should be true\r\nFalse\r\n>>> x  # the repr() is going to lie to us...\r\n<Quantity(1000000000.0, 'nanometer')>\r\n>>> x.magnitude  # caught in the act\r\n999999999.9999999\r\n```\r\nTTD saves the day again!  Huzzah!\r\n"},"comment":{"url":"https://api.github.com/repos/hgrecco/pint/issues/comments/163333114","html_url":"https://github.com/hgrecco/pint/issues/306#issuecomment-163333114","issue_url":"https://api.github.com/repos/hgrecco/pint/issues/306","id":163333114,"user":{"login":"dmwelch","id":961773,"avatar_url":"https://avatars.githubusercontent.com/u/961773?v=3","gravatar_id":"","url":"https://api.github.com/users/dmwelch","html_url":"https://github.com/dmwelch","followers_url":"https://api.github.com/users/dmwelch/followers","following_url":"https://api.github.com/users/dmwelch/following{/other_user}","gists_url":"https://api.github.com/users/dmwelch/gists{/gist_id}","starred_url":"https://api.github.com/users/dmwelch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmwelch/subscriptions","organizations_url":"https://api.github.com/users/dmwelch/orgs","repos_url":"https://api.github.com/users/dmwelch/repos","events_url":"https://api.github.com/users/dmwelch/events{/privacy}","received_events_url":"https://api.github.com/users/dmwelch/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T17:30:40Z","updated_at":"2015-12-09T17:30:40Z","body":"Thanks, @hgrecco for time!  I hope I can explain myself adequately here.\r\n\r\nWe're converting between units and subunits which is handled exactly in Python which most users will expect, IMO.  If I was performing the addition operation in your example, I would expect Pint to behave just as Python (and correct the precision loss or anticipate it).  Pint's behavior introduces error where there shouldn't be any, i.e. a liter is always 1000 milliliters _by definition_.  For example:\r\n\r\n```python\r\n>>> x = 1.0 * 10 ** -9\r\n>>> x  # Correct and expected for conversion between unit and subunits\r\n1e-09\r\n>>> x.as_integer_ratio()\r\n(4835703278458517, 4835703278458516698824704L)\r\n>>> m = ureg.meter()\r\n>>> m.ito('nm')\r\n>>> y = m.magnitude\r\n>>> y  # If I cast to int(), I've lost a nanometer (not due to uncertainty!)\r\n999999999.9999999\r\n>>> y.as_integer_ratio()\r\n(8388607999999999, 8388608)\r\n```\r\nThe docs imply, for better or for worse, that the units are \"tacked on\" and don't affect the computations in any way so it's important that users are aware of this behavior.  Is this an issue in Numpy or Pint and where is it documented?  \r\n\r\nWould it be helpful to add a unit test and mark as an expected failure in case this changes in the future?\r\n\r\n\r\n"}}