what data type to use for storing ids?

hi guys. in java code i will need to use/store ids, that look like 11000000035. what data type to use? long or just String? because int in my case doesnt have enough storage for symbols. thanks
9 Replies
JavaBot
JavaBot3mo ago
This post has been reserved for your question.
Hey @bambyzas! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Tomasm21
Tomasm213mo ago
int is [-2,147,483,648, 2,147,483,647]. 11000000035 is a few timer bigger number. 11000000035 ÷ 2147483647 = 5,1222. long is in range [-9,223,372,036,854,775,808, 9,223,372,036,854,775,807]. 9223372036854775807/11000000035=838488364.31888. Largest long value is 838488364 times bigger. So use either long or string as you need.
JavaBot
JavaBot3mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
galdino
galdino3mo ago
I suggest you use Long(Wrapper) instead of long(primitive) as well. It will save you headaches in the future.
tjoener
tjoener3mo ago
If you always have it, use the primitive
galdino
galdino3mo ago
Why? I mean, in the REST API scenario, I had a headache using primitives as method parameters. Using long, showed up a error. On the other hand, using Long, it worked smoothly.
tjoener
tjoener3mo ago
in the REST API scenario is so vague. But why would you use a NULLABLE type when your number is mandatory? Any half decent serde library should just be able to get the long out
dan1st
dan1st3mo ago
Alternatively, UUID might be an option
JavaBot
JavaBot3mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server