Repository: microsoft/garnet
File: libs/server/Objects/Hash/HashObjectImpl.cs (C#)

Code before:
                        var resultSpan = (Span<byte>)stackalloc byte[NumUtils.MaximumFormatInt64Length];
                        var success = Utf8Formatter.TryFormat((long)result, resultSpan, out int bytesWritten,
                            format: default);
                        Debug.Assert(success);

                        resultSpan = resultSpan.Slice(0, bytesWritten);

                        resultBytes = resultSpan.ToArray();
                        hash[key] = resultBytes;
                        Size += Utility.RoundUp(resultBytes.Length, IntPtr.Size) -
                                Utility.RoundUp(value.Length, IntPtr.Size);
                    }
                    else
                    {
                        resultBytes = incrSlice.SpanByte.ToByteArray();
                        hash.Add(key, resultBytes);
                        UpdateSize(key, resultBytes);
                    }

                    while (!RespWriteUtils.WriteIntegerFromBytes(resultBytes, ref curr, end))
                        ObjectUtils.ReallocateOutput(ref output, ref isMemory, ref ptr, ref ptrHandle, ref curr,
                            ref end);
                }
                else
                {
                    if (!NumUtils.TryParse(incrSlice.ReadOnlySpan, out float incr))
                    {
                        while (!RespWriteUtils.WriteError(CmdStrings.RESP_ERR_NOT_VALID_FLOAT, ref curr, end))
                            ObjectUtils.ReallocateOutput(ref output, ref isMemory, ref ptr, ref ptrHandle, ref curr,
                                ref end);
                        return;
                    }

                    byte[] resultBytes;

                    if (valueExists)
                    {
                        if (!NumUtils.TryParse(value, out float result))
                        {
                            while (!RespWriteUtils.WriteError(CmdStrings.RESP_ERR_HASH_VALUE_IS_NOT_FLOAT, ref curr,
                                       end))
                                ObjectUtils.ReallocateOutput(ref output, ref isMemory, ref ptr, ref ptrHandle, ref curr,
                                    ref end);
                            return;
                        }

                        result += incr;

                        resultBytes = Encoding.ASCII.GetBytes(result.ToString(CultureInfo.InvariantCulture));
                        hash[key] = resultBytes;
                        Size += Utility.RoundUp(resultBytes.Length, IntPtr.Size) -

Review comment (suggestion):
If you change the datatype from `float` to `double` you have to change the logic on how the double is converted into a string. Because `result.ToString(CultureInfo.InvariantCulture)` will give value in explorational notation eg: 0.00001 double value will be shown as `1E-5` but when we do `HGET` it should show the value as `0.00001` not `1E-5`. You have to make changes in the below 2 places for that.

https://github.com/microsoft/garnet/blob/b2448121ce2ddc3c0850cfd12dea25c42fb3e529/libs/server/Objects/Hash/HashObjectImpl.cs#L419

https://github.com/microsoft/garnet/blob/b2448121ce2ddc3c0850cfd12dea25c42fb3e529/libs/server/Objects/Hash/HashObjectImpl.cs#L426

Code after:
                        var resultSpan = (Span<byte>)stackalloc byte[NumUtils.MaximumFormatInt64Length];
                        var success = Utf8Formatter.TryFormat((long)result, resultSpan, out int bytesWritten,
                            format: default);
                        Debug.Assert(success);

                        resultSpan = resultSpan.Slice(0, bytesWritten);

                        resultBytes = resultSpan.ToArray();
                        hash[key] = resultBytes;
                        Size += Utility.RoundUp(resultBytes.Length, IntPtr.Size) -
                                Utility.RoundUp(value.Length, IntPtr.Size);
                    }
                    else
                    {
                        resultBytes = incrSlice.SpanByte.ToByteArray();
                        hash.Add(key, resultBytes);
                        UpdateSize(key, resultBytes);
                    }

                    while (!RespWriteUtils.WriteIntegerFromBytes(resultBytes, ref curr, end))
                        ObjectUtils.ReallocateOutput(ref output, ref isMemory, ref ptr, ref ptrHandle, ref curr,
                            ref end);
                }
                else
                {
                    if (!NumUtils.TryParse(incrSlice.ReadOnlySpan, out double incr))
                    {
                        while (!RespWriteUtils.WriteError(CmdStrings.RESP_ERR_NOT_VALID_FLOAT, ref curr, end))
                            ObjectUtils.ReallocateOutput(ref output, ref isMemory, ref ptr, ref ptrHandle, ref curr,
                                ref end);
                        return;
                    }

                    byte[] resultBytes;

                    if (valueExists)
                    {
                        if (!NumUtils.TryParse(value, out double result))
                        {
                            while (!RespWriteUtils.WriteError(CmdStrings.RESP_ERR_HASH_VALUE_IS_NOT_FLOAT, ref curr,
                                       end))
                                ObjectUtils.ReallocateOutput(ref output, ref isMemory, ref ptr, ref ptrHandle, ref curr,
                                    ref end);
                            return;
                        }

                        result += incr;

                        resultBytes = Encoding.ASCII.GetBytes(result.ToString(CultureInfo.InvariantCulture));
                        hash[key] = resultBytes;
                        Size += Utility.RoundUp(resultBytes.Length, IntPtr.Size) -