public void WriteDouble(LazyNumberValue val)
        {
            if (val.IsNaN())
            {
                WriteBufferFor(NaNBuffer);
                return;
            }

            if (val.IsPositiveInfinity())
            {
                WriteBufferFor(PositiveInfinityBuffer);
                return;
            }

            if (val.IsNegativeInfinity())
            {
                WriteBufferFor(NegativeInfinityBuffer);
                return;
            }

            var lazyStringValue = val.Inner;

            EnsureBuffer(lazyStringValue.Size);
            WriteRawString(lazyStringValue.Buffer, lazyStringValue.Size);
        }
Exemple #2
0
        protected bool Equals(LazyNumberValue other)
        {
            if (_val != null && other._val != null)
            {
                return(Math.Abs(_val.Value - other._val.Value) < double.Epsilon);
            }

            if (_decimalVal != null && other._decimalVal != null)
            {
                return(_decimalVal.Value.Equals(other._decimalVal.Value));
            }

            return(Inner.Equals(other.Inner));
        }
Exemple #3
0
        protected bool Equals(LazyNumberValue other)
        {
            if (_val != null && other._val != null)
            {
                return(_val.Value.AlmostEquals(other._val.Value));
            }

            if (_decimalVal != null && other._decimalVal != null)
            {
                return(_decimalVal.Value.Equals(other._decimalVal.Value));
            }

            return(Inner.Equals(other.Inner));
        }
Exemple #4
0
        public void WriteValue(LazyNumberValue value)
        {
            var currentState = _continuationState.Pop();
            var valuePos = _writer.WriteValue(value);
            _writeToken = new WriteToken
            {
                ValuePos = valuePos,
                WrittenToken = BlittableJsonToken.LazyNumber
            };

            if (currentState.FirstWrite == -1)
                currentState.FirstWrite = valuePos;

            currentState = FinishWritingScalarValue(currentState);
            _continuationState.Push(currentState);
        }
        public void WriteValue(LazyNumberValue value)
        {
            var currentState = _continuationState.Pop();
            var valuePos     = _writer.WriteValue(value);

            _writeToken = new WriteToken //todo: figure out if we really need those WriteTokens
            {
                ValuePos     = valuePos,
                WrittenToken = BlittableJsonToken.LazyNumber
            };

            if (currentState.FirstWrite == -1)
            {
                currentState.FirstWrite = valuePos;
            }

            currentState = FinishWritingScalarValue(currentState);
            _continuationState.Push(currentState);
        }
Exemple #6
0
 public int WriteValue(LazyNumberValue value)
 {
     return(WriteValue(value.Inner));
 }
Exemple #7
0
 private static void ThrowInvalidNumberFormat(LazyNumberValue self, string type)
 {
     throw new InvalidCastException($"Unable to convert '{self.Inner}' to a {type}");
 }