Skip to content

Commit

Permalink
修复浮点数序列化问题
Browse files Browse the repository at this point in the history
  • Loading branch information
davyxu committed Aug 21, 2020
1 parent 65680aa commit 5e9634a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ example/csharp/Example/bin
example/csharp/Example/obj
example/csharp/ProtoPlus/obj
example/csharp/ProtoPlus/bin
api/csharp/ProtoPlus/bin
api/csharp/ProtoPlus/obj
4 changes: 2 additions & 2 deletions example/csharp/ProtoPlus/OutputStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void WriteUInt64(int fieldIndex, List<ulong> value)

public void WriteFloat(int fieldIndex, float value)
{
if (value < float.Epsilon)
if (value == 0F)
{
return;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ public void WriteFloat(int fieldIndex, List<float> value)

public void WriteDouble(int fieldIndex, double value)
{
if (value < double.Epsilon)
if (value == 0D)
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions example/csharp/ProtoPlus/SizeCaculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static int SizeEnum<T>(int fieldIndex, List<T> value) where T : struct, I

public static int SizeFloat(int fieldIndex, float value)
{
if (value < float.Epsilon)
if (value == 0F)
{
return 0;
}
Expand All @@ -100,7 +100,7 @@ public static int SizeFloat(int fieldIndex, List<float> value)

public static int SizeDouble(int fieldIndex, double value)
{
if (value < double.Epsilon)
if (value == 0D)
{
return 0;
}
Expand Down

0 comments on commit 5e9634a

Please sign in to comment.