Skip to content

Commit

Permalink
Remove BigDecimal precision field
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens committed Mar 28, 2024
1 parent 0b0969b commit 1f8d3f0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ private static ProtoBigDecimal serializeBigDecimal( BigDecimal bigDecimal ) {
return ProtoBigDecimal.newBuilder()
.setUnscaledValue( ByteString.copyFrom( bigDecimal.unscaledValue().toByteArray() ) )
.setScale( bigDecimal.scale() )
.setPrecision( bigDecimal.precision() )
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,8 @@ private static PolyBigDecimal deserializeToPolyBigDecimal( ProtoValue protoValue

private static BigDecimal deserializeToBigDecimal( ProtoValue protoValue ) {
ProtoBigDecimal protoBigDecimal = protoValue.getBigDecimal();
MathContext context = new MathContext( protoBigDecimal.getPrecision() );
byte[] unscaledValue = protoBigDecimal.getUnscaledValue().toByteArray();
return new BigDecimal( new BigInteger( unscaledValue ), protoBigDecimal.getScale(), context );
return new BigDecimal( new BigInteger( unscaledValue ), protoBigDecimal.getScale() );
}

}
4 changes: 2 additions & 2 deletions plugins/proto-interface/src/main/proto/polyprism/value.proto
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ Represents a BigDecimal value with specified precision and scale.
*/
message ProtoBigDecimal {
// The scale of the BigDecimal.
uint32 scale = 1;
int32 scale = 1;
// The precision of the BigDecimal.
uint32 precision = 2;
uint32 precision = 2; // TODO: Currently unused
// The unscaled value of the BigDecimal.
bytes unscaled_value = 3;
}
Expand Down

0 comments on commit 1f8d3f0

Please sign in to comment.