Development with AWS Services

A JavaScript application reads DynamoDB Number attributes containing integers larger than JavaScript's safe integer range and must write them back unchanged as numbers. Which approach preserves both precision and the DynamoDB attribute type?

Show the answer

Correct answerB. Use lossless numeric handling and write the exact value as a Number attribute.

AWhy not this: The digits remain intact, but changing the attribute to String violates the numeric-type requirement.

BWhy this is right: Lossless handling retains the exact digits, and a Number attribute retains DynamoDB's numeric type.

CWhy not this: Rounding changes the stored value even though the DynamoDB attribute remains numeric.

DWhy not this: JavaScript Number cannot exactly represent every integer beyond its safe integer range.

Lossless handling preserves the integer's exact value, while a DynamoDB Number attribute preserves its numeric type. DynamoDB transmits numbers as strings, but converting those strings to JavaScript Number can lose precision.