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

adding code to generate hexadecimal numbers in java tests #1061

Conversation

eigold
Copy link
Contributor

@eigold eigold commented Jun 26, 2017

No description provided.

@@ -960,7 +960,8 @@ bool interpretert::unbounded_size(const typet &type)
size_t interpretert::get_size(const typet &type)
{
if(unbounded_size(type))
return 2ULL << 32ULL;
return 1ULL << 31ULL;
//return 2ULL << 32ULL;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems unrelated to the actual change. It's also not clear why it's needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is required for 32 bit systems, as the original code is UB for those, it's not yet obvious how to fix this in general for 32 bit
Still, it should not be part of this PR

Copy link
Member

Choose a reason for hiding this comment

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

Please remove code instead of commenting out

buffer << D;
return(buffer.str());
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems a bit clunky but I think that's just what C++ forces you to do. Other than that; looks good.

martin-cs
martin-cs previously approved these changes Jun 27, 2017
@mgudemann mgudemann self-requested a review June 27, 2017 08:08
@@ -235,6 +237,23 @@ std::string expr2javat::convert_constant(
dest+='L';
return dest;
}
else if (src.type() == java_float_type()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please also run the scripts/cpplint.py script on this
For example, there should be no spaces around = or == or after if

@@ -235,6 +237,23 @@ std::string expr2javat::convert_constant(
dest+='L';
return dest;
}
else if (src.type() == java_float_type()) {
ieee_floatt Fpn(to_constant_expr(src));
Copy link
Member

Choose a reason for hiding this comment

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

Do not use upper case in identifiers.

std::stringstream buffer;
buffer << std::hexfloat;
buffer << F << 'f';
return(buffer.str());
Copy link
Member

Choose a reason for hiding this comment

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

return buffer.str(); (several occurrences)

float F = Fpn.to_float();
std::stringstream buffer;
buffer << std::hexfloat;
buffer << F << 'f';
Copy link
Member

Choose a reason for hiding this comment

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

You could merge this with the previous statement to make it shorter

@eigold
Copy link
Contributor Author

eigold commented Jun 27, 2017 via email

@mgudemann
Copy link
Contributor

@eigold no worries, for the "in progress", this means basically that you are working on it and yes, "ready to Review" will be the next step. But I have to admit that this is not always treated as it should be :-)

@@ -960,7 +960,8 @@ bool interpretert::unbounded_size(const typet &type)
size_t interpretert::get_size(const typet &type)
{
if(unbounded_size(type))
return 2ULL << 32ULL;
return 1ULL << 31ULL;
//return 2ULL << 32ULL;
Copy link
Member

Choose a reason for hiding this comment

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

Please remove code instead of commenting out

@eigold
Copy link
Contributor Author

eigold commented Jun 30, 2017 via email

@peterschrammel
Copy link
Member

Then this should be fixed in the interpreter to work on 32bit systems (can be done as a separate PR).

@eigold
Copy link
Contributor Author

eigold commented Jun 30, 2017 via email

@mgudemann
Copy link
Contributor

mgudemann commented Jun 30, 2017 via email

@mgudemann
Copy link
Contributor

@eigold could you please change the PR, so that it does not contain the change to interpreter.cpp
This can be done by editing the commit and only staging/committing the other changes. This should be described under "interactive rebase" in more git resources. After then, you can push --force the changed commit.
You can also undo the change, commit that change and then squash the commits, again via interactive rebase.

@eigold eigold force-pushed the feature/hexadecimal_float_output_in_expr2java branch from acf1da9 to e46a320 Compare July 3, 2017 09:40
@peterschrammel
Copy link
Member

@eigold, any progress on this?

@eigold
Copy link
Contributor Author

eigold commented Jul 3, 2017 via email

@mgudemann
Copy link
Contributor

@eigold as one of the last commits says "starting a new branch" could it be that the newer commit are simply in a different, new branch? Only commits pushed to eigold:feature/hexadecimal_float_output_in_expr2java will appear here

@eigold
Copy link
Contributor Author

eigold commented Jul 3, 2017 via email

@mgudemann
Copy link
Contributor

@eigold all these commits are shown on github then. You just have to scroll down, "removing and accidental change" is just right in front of Peter's last comment

@eigold
Copy link
Contributor Author

eigold commented Jul 3, 2017 via email

if(ieee_repr.is_NaN())
result+="NaN";
else
result+="inf";
Copy link
Contributor

Choose a reason for hiding this comment

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

for Java, this is Double/Float.NEGATIVE_INFINITY or Double/Float.POSITIVE_INFINITY
(cf. https://docs.oracle.com/javase/7/docs/api/java/lang/Float.html)

else
result="+";
if(ieee_repr.is_NaN())
result+="NaN";
Copy link
Contributor

Choose a reason for hiding this comment

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

for Java, this is Float/Double.NaN

std::stringstream buffer;
buffer << std::hexfloat;
buffer << D;
if(float_flag)
buffer << f_num << 'f';
Copy link
Contributor

Choose a reason for hiding this comment

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

please simplify to buffer << ieee_repr.to_float() << 'f';

if(float_flag)
buffer << f_num << 'f';
else
buffer << d_num;
Copy link
Contributor

Choose a reason for hiding this comment

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

as above

std::stringstream buffer;
buffer << std::hexfloat;
buffer << D;
if(float_flag)
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick, explicit bool is not needed, if(src.type()==java_float_type()) would be enough

@eigold
Copy link
Contributor Author

eigold commented Jul 6, 2017 via email

@mgudemann
Copy link
Contributor

mgudemann commented Jul 6, 2017 via email

@eigold
Copy link
Contributor Author

eigold commented Jul 6, 2017 via email

@mgudemann
Copy link
Contributor

mgudemann commented Jul 6, 2017 via email

@eigold
Copy link
Contributor Author

eigold commented Jul 6, 2017 via email

@mgudemann
Copy link
Contributor

mgudemann commented Jul 6, 2017 via email

@eigold
Copy link
Contributor Author

eigold commented Jul 6, 2017 via email

Copy link
Contributor

@mgudemann mgudemann left a comment

Choose a reason for hiding this comment

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

LGTM, please squash commits

  removed an accidental change, added code to process special cases: NaN and infiinity
  made required simplications, made corrections in treatment of special cases
@eigold eigold force-pushed the feature/hexadecimal_float_output_in_expr2java branch from 664cda2 to 9b2e643 Compare July 12, 2017 21:58
@eigold
Copy link
Contributor Author

eigold commented Jul 12, 2017 via email

@mgudemann
Copy link
Contributor

obsoleted by #1216

@mgudemann mgudemann closed this Aug 8, 2017
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.

4 participants