You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2020/06/04 09:29:56 UTC

[GitHub] [dubbo-go-hessian2] willson-chen commented on pull request #196: Fix #181: float32 accuracy issue

willson-chen commented on pull request #196:
URL: https://github.com/apache/dubbo-go-hessian2/pull/196#issuecomment-638734560


   I referenced [dubbo-hessian-lite/PR#12](https://github.com/apache/dubbo-hessian-lite/pull/12) to create this patch.
   
   Adding `func encFloat32` is a good choice. And then we should encode the float32 directly indead of casting it to float64. BTW, casting causes the accuracy issue. But I am not sure if it will introduce any compatibility issues.
   
   ```
   double     ::= 'D' b7 b6 b5 b4 b3 b2 b1 b0   # 64-bit float
              ::= x5b                   # 0.0
              ::= x5c                   # 1.0
              ::= x5d b0                # byte cast to double
                                        #  (-128.0 to 127.0)
              ::= x5e b1 b0             # short cast to double
              ::= x5f b3 b2 b1 b0       # 32-bit float cast to double
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org