* Get the decimal value * @this {!FieldModelDecimal} * @param {Big=} defaults Default value, defaults is new Big(0) * @returns {!Big} Result value
(defaults = new Big(0))
| 1752 | * @returns {!Big} Result value |
| 1753 | */ |
| 1754 | get (defaults = new Big(0)) { |
| 1755 | if ((this._buffer.offset + this.fbeOffset + this.fbeSize) > this._buffer.size) { |
| 1756 | return defaults |
| 1757 | } |
| 1758 | |
| 1759 | // Read decimal parts |
| 1760 | let low = this.readUInt32(this.fbeOffset) |
| 1761 | let mid = this.readUInt32(this.fbeOffset + 4) |
| 1762 | let high = this.readUInt32(this.fbeOffset + 8) |
| 1763 | let flags = this.readUInt32(this.fbeOffset + 12) |
| 1764 | |
| 1765 | // Calculate decimal value |
| 1766 | let negative = (flags & 0x80000000) !== 0 |
| 1767 | let scale = (flags & 0x7FFFFFFF) >> 16 |
| 1768 | let result = new Big(0) |
| 1769 | result = result.add(new Big(high).mul('18446744073709551616')) |
| 1770 | result = result.add(new Big(mid).mul('4294967296')) |
| 1771 | result = result.add(new Big(low)) |
| 1772 | result = result.div(Math.pow(10, scale)) |
| 1773 | if (negative) { |
| 1774 | result.s = -1 |
| 1775 | } |
| 1776 | |
| 1777 | return result |
| 1778 | } |
| 1779 | |
| 1780 | /** |
| 1781 | * Set the decimal value |
no test coverage detected