ReadFloat64 reads the float64 value for the tag and the require or optional sign.
(data *float64, tag byte, require bool)
| 804 | |
| 805 | // ReadFloat64 reads the float64 value for the tag and the require or optional sign. |
| 806 | func (b *Reader) ReadFloat64(data *float64, tag byte, require bool) error { |
| 807 | have, ty, err := b.SkipToNoCheck(tag, require) |
| 808 | if err != nil { |
| 809 | return err |
| 810 | } |
| 811 | if !have { |
| 812 | return nil |
| 813 | } |
| 814 | |
| 815 | switch ty { |
| 816 | case ZeroTag: |
| 817 | *data = 0 |
| 818 | case FLOAT: |
| 819 | var tmp uint32 |
| 820 | err = bReadU32(b.buf, &tmp) |
| 821 | *data = float64(math.Float32frombits(tmp)) |
| 822 | case DOUBLE: |
| 823 | var tmp uint64 |
| 824 | err = bReadU64(b.buf, &tmp) |
| 825 | *data = math.Float64frombits(tmp) |
| 826 | default: |
| 827 | return fmt.Errorf("read 'double' type mismatch, tag:%d, get type:%s", tag, getTypeStr(int(ty))) |
| 828 | } |
| 829 | |
| 830 | if err != nil { |
| 831 | err = fmt.Errorf("read 'float64' tag:%d error:%v", tag, err) |
| 832 | } |
| 833 | return err |
| 834 | } |
| 835 | |
| 836 | // ReadString reads the string value for the tag and the require or optional sign. |
| 837 | func (b *Reader) ReadString(data *string, tag byte, require bool) error { |