Opened 7 years ago
Closed 7 years ago
#28730 closed Bug (fixed)
Large integer literals lose precision in templates
Reported by: | Fraser Nevett | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
While looking at #28721, I realised that there is loss of precision on large integer literals:
>>> from django.template import Template, Context >>> Template('{{ 999999999999999999999999999 }}').render(Context()) u'1000000000000000013287555072'
This happens because the code tries to first convert literal values to a float and then from the float to an int, which is a lossy operation.
Change History (5)
comment:1 by , 7 years ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 7 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 7 years ago
Has patch: | set |
---|---|
Version: | 1.11 → master |
comment:4 by , 7 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
PR