Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix inconsistency between floating-point number's storage and output in TDB/deps/common/lang/string.cpp #13

Merged
merged 2 commits into from
Apr 25, 2024

Conversation

ntw2020
Copy link
Contributor

@ntw2020 ntw2020 commented Apr 24, 2024

问题:浮点数的存储和输出格式不一致导致无法精确查找

描述:现有TDB的float存储时未作截断,打印时截断至两位小数导致无法精确查找。因此取消打印时的位数截断。

image

分析:直接打印为 %f 不会因为缓冲区导致截断

float的阶码为8位,尾数为23位。
规格化最大正数为:2^24-1)x2^(127-23) = (2^24-1)x2^104,即 3.4028235E+38
规格化最小正数为:1x2^(-126),即1.1754943E-38
非规格化最小正数为:2^(-23)x2^(-126)=2^(-149),即1.401298E-45
均不会超过分配的256字节的缓冲区buf,因此可以完整输出。

Copy link
Member

@ycycse ycycse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@ycycse ycycse merged commit a43bd5f into THSS-DB:master Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants