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

Type of operations #45

Open
Saginsky opened this issue Mar 26, 2020 · 6 comments
Open

Type of operations #45

Saginsky opened this issue Mar 26, 2020 · 6 comments

Comments

@Saginsky
Copy link

I was wondering if something like
int main()
{
double a = 13.7;
while (a < 5.9){
a = a - 1.1;
}
}

would be tested. I am asking because this means that the assembly generated for the comparison can only be determined by looking at the type of the variable within it i.e. a which is a double. This means that we need to do a double precision comparison. From god-bolt there doesn't seem to be any casting involved here just a double precision version of a while loop. Thanks!

@ymherklotz
Copy link
Member

I believe that could be tested, yes.

@JaafarRammal
Copy link
Member

JaafarRammal commented Mar 27, 2020

@ymherklotz I assume the following is a wrong syntax:

...
float a = 3.4;
while(a < 1.2)
...

and should be:

float a = 3.4;
while(a < 1.2f)

I assume therefore that since in our tests there won't be any casting, floating point constant will always be followed by an f

In other words, we can safely remove the last character in a floating point constant assignment. The following would therefore be invalid:

float a = 3.4;

and should be:

float a = 3.4f;

@tobhil98
Copy link
Member

Correct, decimal values without the f should be treated as doubles.

@JaafarRammal
Copy link
Member

Another question @tobhil98

Can we assume no hex assignment will be used for floating points? Otherwise if we have something like float a = 0xFFF \\or double do we have to remove the last F to convert it or not? Compilers online don't seem to remove and prioritize the hexadecimal representation in the lexer over the floating point indicator, hence cast it from double into float.

@tobhil98
Copy link
Member

Yeah, I would say hex values should be treated as integers, but I'm not entirely sure.

@ymherklotz
Copy link
Member

Yeah I would agree, I doubt hex representation will be used to initialise floats and doubles.

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

No branches or pull requests

4 participants