Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

f64 for octal binary hexadecimal #128

Closed
wants to merge 1 commit into from
Closed

f64 for octal binary hexadecimal #128

wants to merge 1 commit into from

Conversation

tolbon
Copy link

@tolbon tolbon commented Dec 17, 2017

I begin Rust so all comments is welcome.
I don't know if this is like you think this commit.

this PR try to close #44 Issues

Ps : Just thinking about that when I read code, but why Integer is i64 and not i32 ?

@coveralls
Copy link

coveralls commented Dec 18, 2017

Coverage Status

Coverage remained the same at 96.125% when pulling 347a7a2 on tolbon:BinaryOctalHexa2f64 into 87d42c3 on tagua-vm:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.125% when pulling 347a7a2 on tolbon:BinaryOctalHexa2f64 into 87d42c3 on tagua-vm:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.125% when pulling 347a7a2 on tolbon:BinaryOctalHexa2f64 into 87d42c3 on tagua-vm:master.

Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

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

Thank you for your PR!

I am the culprit here because #44 does not provide an example, but the goal is: Binary, octal, and hexadecimal must be f64 (reals) when it does not fit in i64 (integer).

@@ -331,7 +331,7 @@ fn hexadecimal_mapper(span: Span) -> StdResult<Literal, ParseIntError> {
)
.and_then(
|hexadecimal| {
Ok(Literal::Integer(Token::new(hexadecimal, span)))
Ok(Literal::Real(Token::new(hexadecimal as f64, span)))
Copy link
Member

Choose a reason for hiding this comment

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

I understand what you did here. Excuse me if it was not clear in #44, but the goal is that it must overflow to a real.

When the hexadecimal value does not fit in i64 (Literal::Integer), it must be then be a f64 (Literal::Real).

Moving everything to real is not optimized, and can complicate things later.

Copy link
Author

Choose a reason for hiding this comment

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

Aaaah ok, I understand, more stuff like decimal rules ?

i64::from_str(string)
        .and_then(...)
        .or_else(
            |_: ParseIntError| {
                f64::from_str(string).and_then(...)
            }

Copy link
Member

@Hywan Hywan Dec 18, 2017

Choose a reason for hiding this comment

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

Correct. But that's not trivial. In Zend Engine, this conversion from hexa to real is wrong most of the time, and the specification says nothing about that. So that's not a trivial things to do. Maybe there is a crate on crates.io to help us.

Copy link
Author

Choose a reason for hiding this comment

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

I forget that => bug-compliance that's wright ? Maybe I delete this PR cause more complicated than expected

Copy link
Member

Choose a reason for hiding this comment

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

I haven't decided yet if we should be bug-compliant here or not. I guess not, and then I would have to fix Zend Engine. That's the best we can do. But until that, yes, if this task is too difficult, feel free to close this PR :-). Would you like another one?

Copy link
Author

Choose a reason for hiding this comment

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

Yes of course :)

Copy link
Member

Choose a reason for hiding this comment

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

#92 this one might be easy :-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Literal: Binary, octal and hexadecimal must overflow to real
3 participants