1 /* 2 * hunt-proton: AMQP Protocol library for D programming language. 3 * 4 * Copyright (C) 2018-2019 HuntLabs 5 * 6 * Website: https://www.huntlabs.net/ 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 12 module hunt.proton.amqp.Decimal64; 13 14 import hunt.math; 15 import hunt.Number; 16 17 class Decimal64 : Number 18 { 19 private BigDecimal _underlying; 20 private long _bits; 21 22 this(BigDecimal underlying) 23 { 24 _underlying = underlying; 25 _bits = calculateBits(underlying); 26 27 } 28 29 30 this(long bits) 31 { 32 _bits = bits; 33 _underlying = calculateBigDecimal(bits); 34 } 35 36 static BigDecimal calculateBigDecimal(long bits) 37 { 38 return BigDecimal.ZERO; 39 } 40 41 static long calculateBits(BigDecimal underlying) 42 { 43 return 0; // TODO 44 } 45 46 47 override 48 public int intValue() 49 { 50 return _underlying.intValue(); 51 } 52 53 override 54 public long longValue() 55 { 56 return _underlying.longValue(); 57 } 58 59 override 60 public float floatValue() 61 { 62 return _underlying.floatValue(); 63 } 64 65 override 66 public double doubleValue() 67 { 68 return _underlying.doubleValue(); 69 } 70 71 public long getBits() 72 { 73 return _bits; 74 } 75 76 override bool opEquals(Object o) 77 { 78 if (this is o) 79 { 80 return true; 81 } 82 if (o is null || cast(Decimal64)o is null) 83 { 84 return false; 85 } 86 87 Decimal64 decimal64 = cast(Decimal64)o; 88 89 if (_bits != decimal64._bits) 90 { 91 return false; 92 } 93 94 return true; 95 } 96 97 98 override 99 byte byteValue() 100 { 101 return 1; 102 } 103 104 override short shortValue() 105 { 106 return 1; 107 } 108 109 override string toString() 110 { 111 return ""; 112 } 113 }