Skip to content
aymericbeaumet edited this page Jan 3, 2015 · 7 revisions

Frequently Asked Questions

Why doesn't tweet.id contain the correct id? (#126)

TLDR: JavaScript does not support such big numbers without losing precision, do use tweet.id_str instead.

Explanations: current JavaScript implementations follow the IEEE 754 standard and therefore represents numeric values as double precision 64 bit floating point numbers. Those bits are split in three parts:

  • value: 52 bits
  • exponent: 11 bits
  • sign: 1 bit

This allows to store at most 53 bits, thus being too small to store Twitter ids which are 64 bit unsigned integers. Therefore when the Twitter API messages are parsed (using JSON.parse), it only stores a numeric approximation of the tweet id. The precise value is still accessible at tweet.id_str as a string (hence unaltered).

Read more on this topic via this Twitter article.

If you really need to support huge numbers, look forward for libraries like bignumbers.js and rely on tweet.id_str.

Clone this wiki locally