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

Problem with select float in E-notation format #317

Closed
chrudosvorlicek opened this issue Oct 22, 2018 · 3 comments · Fixed by #321
Closed

Problem with select float in E-notation format #317

chrudosvorlicek opened this issue Oct 22, 2018 · 3 comments · Fixed by #321

Comments

@chrudosvorlicek
Copy link
Contributor

Version: I'm using v3.2.3, but it is also in master

Bug Description

When selecting float number in e-notation (e.g. 1.1e+10) class \Dibi\Result rtrims the zero, which causes change of output value (1.1e+10 is selected as 1.1e+1).

Steps To Reproduce

just try to select float number in e-notation from database.

Expected Behavior

If the number is in e-notation, leave rigth zeros.

Possible Solution

In class \Dibi\Result in private function normalize in part where $type === Type::FLOAT add check if number is in e-notation format and if it is, do not perform rtrim on zeros. It can be something like this:
$p = strpos($value, '.'); $e = strpos($value, 'e'); if ($p !== false && $e === false) { $value = rtrim(rtrim($value, '0'), '.'); } elseif ($p !== false && $e !== false) { $value = rtrim($value, '.'); }

@dg
Copy link
Owner

dg commented Oct 22, 2018

Can you send pull request?

@chrudosvorlicek
Copy link
Contributor Author

If suggested solution is ok for you, I can do it.

@dg
Copy link
Owner

dg commented Oct 22, 2018

I think it is ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants