diff --git a/src/MongoDB.Bson/ObjectModel/Decimal128.cs b/src/MongoDB.Bson/ObjectModel/Decimal128.cs index 3320e7dc37b..0853fdf99e1 100644 --- a/src/MongoDB.Bson/ObjectModel/Decimal128.cs +++ b/src/MongoDB.Bson/ObjectModel/Decimal128.cs @@ -1523,6 +1523,25 @@ public Decimal128(Half value) } #endif + /// + /// Initializes a new instance of the struct. + /// + /// The value. + [CLSCompliant(false)] + public Decimal128(sbyte value) + { + if (value >= 0) + { + _highBits = 0; + _lowBits = (ulong)value; + } + else + { + _highBits = Flags.SignBit; + _lowBits = value == sbyte.MinValue ? (ulong)sbyte.MaxValue + 1 : (ulong)-value; + } + } + /// /// Initializes a new instance of the struct. /// @@ -1559,6 +1578,16 @@ public Decimal128(long value) } } + /// + /// Initializes a new instance of the struct. + /// + /// The value. + public Decimal128(byte value) + { + _highBits = 0; + _lowBits = value; + } + /// /// Initializes a new instance of the struct. ///