Code RoomLarge IDs lose precision
HardPrep Room Coding #4526

Large IDs lose precision

Code reviewCode quality & reviewSenior–Staff~20 min

Review this Java code that reads a Snowflake-style 64-bit ID out of an inbound JSON payload with Jackson's tree model.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1ObjectMapper mapper = new ObjectMapper();
2 
3long parseId(String json) throws Exception {
4 JsonNode root = mapper.readTree(json);
5 // json is like {"id": 1541815603606036480}
6 double v = root.get("id").asDouble();
7 return (long) v;
8}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.