Fellow Stranger
Fellow Stranger

Reputation: 34013

Max number for ActiveModel::Type::Integer

I'm trying to store the number 3980040429 as an ID for an object, but I'm etting the following error:

ActiveModel::RangeError (3980040429 is out of range for ActiveModel::Type::Integer with limit 4 bytes)

Doesn't the 4 bytes equal to 4 294 967 296?

4 bytes × 8 bits = 32 bits 
2³² = 4 294 967 296

As I'm appearantly wrong - what's the max integer I can save for an ID?

I'm on Rails 5.2 and Postgres 9.6.

Upvotes: 5

Views: 2959

Answers (1)

Purplejacket
Purplejacket

Reputation: 2118

It's a signed 4 byte integer.

So the maximum value it can have is 2³¹ - 1

2147483647

Upvotes: 4

Related Questions