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

Numbers in scientific notation not recognized as floats in 3.0 #4190

Closed
hamoid opened this Issue Dec 6, 2015 · 8 comments

Comments

Projects
None yet
5 participants
@hamoid
Contributor

hamoid commented Dec 6, 2015

This used to be possible:

rotate(90e1);

In 3.0 it complains that 90e1 is not a float. Also

rotate(float(90e1)); 

does not work, but

rotate((float)90e1); 

does.

@djokjulapfe

This comment has been minimized.

Show comment
Hide comment
@djokjulapfe

djokjulapfe Dec 7, 2015

You have to put 90.0e1. Notice de .0 I added. 90e1 creates a double, and rotate works only with floats.

djokjulapfe commented Dec 7, 2015

You have to put 90.0e1. Notice de .0 I added. 90e1 creates a double, and rotate works only with floats.

@hamoid

This comment has been minimized.

Show comment
Hide comment
@hamoid

hamoid Dec 7, 2015

Contributor

Good to know. But my point is that this behaviour changed. It used to work without the .0 in previous versions, and old programs I wrote stopped working. Maybe it was announced and I missed it.

Contributor

hamoid commented Dec 7, 2015

Good to know. But my point is that this behaviour changed. It used to work without the .0 in previous versions, and old programs I wrote stopped working. Maybe it was announced and I missed it.

@Akarshit

This comment has been minimized.

Show comment
Hide comment
@Akarshit

Akarshit Dec 11, 2015

Member

From what i could see, some of the conversion functions have been remove like boolean(), byte(), char(), float(), int(). This is the reason for

rotate(float(90e1));

to not work. But they are still given as a part of the reference in 3.0 (like for float() here).

Member

Akarshit commented Dec 11, 2015

From what i could see, some of the conversion functions have been remove like boolean(), byte(), char(), float(), int(). This is the reason for

rotate(float(90e1));

to not work. But they are still given as a part of the reference in 3.0 (like for float() here).

@hamoid

This comment has been minimized.

Show comment
Hide comment
@hamoid

hamoid Dec 11, 2015

Contributor

@Akarshit are you sure they have been removed? They work all right in my 3.0.

println(float(22000)); // works, float() is there
println((float)22e3); // works, but 22e3 interpreted as double, converted to float
println(float(22e3)); // not  working. can't convert double to float with float()

I'm wondering, though, since I see no mention of the scientific notation in the documentation, even if the behavior changed without notice, if this issue can be closed? Nothing was ever promised regarding scientific notation, right? Only some of my http://funprogramming.org/p5tweets/ broke, which is to be expected anyway :)

Contributor

hamoid commented Dec 11, 2015

@Akarshit are you sure they have been removed? They work all right in my 3.0.

println(float(22000)); // works, float() is there
println((float)22e3); // works, but 22e3 interpreted as double, converted to float
println(float(22e3)); // not  working. can't convert double to float with float()

I'm wondering, though, since I see no mention of the scientific notation in the documentation, even if the behavior changed without notice, if this issue can be closed? Nothing was ever promised regarding scientific notation, right? Only some of my http://funprogramming.org/p5tweets/ broke, which is to be expected anyway :)

@Akarshit

This comment has been minimized.

Show comment
Hide comment
@Akarshit

Akarshit Dec 11, 2015

Member

@hamoid Sorry my bad, i got confused somewhere.

Member

Akarshit commented Dec 11, 2015

@hamoid Sorry my bad, i got confused somewhere.

@GoToLoop

This comment has been minimized.

Show comment
Hide comment
@GoToLoop

GoToLoop Jan 26, 2016

@hamoid , 22e3 isn't interpreted as double in the PDE. We have to suffix it w/ d or D for it:

float f1 = 22.e3;  // works
float f2 = 22.e3d; // cannot convert from double to float

PDE's pre-processor visits each numerical literal in the ".pde" source and suffix w/ an f to every 1 which got a . or an e on it. Of course, as long as they don't have 1 already. ;-)

GoToLoop commented Jan 26, 2016

@hamoid , 22e3 isn't interpreted as double in the PDE. We have to suffix it w/ d or D for it:

float f1 = 22.e3;  // works
float f2 = 22.e3d; // cannot convert from double to float

PDE's pre-processor visits each numerical literal in the ".pde" source and suffix w/ an f to every 1 which got a . or an e on it. Of course, as long as they don't have 1 already. ;-)

@GoToLoop

This comment has been minimized.

Show comment
Hide comment
@GoToLoop

GoToLoop Jan 26, 2016

println(float(22e3)); // not working. can't convert double to float with float()

The actual compile error is: "The method parseFloat(int) in the type PApplet is not applicable for the argument (float)"

GoToLoop commented Jan 26, 2016

println(float(22e3)); // not working. can't convert double to float with float()

The actual compile error is: "The method parseFloat(int) in the type PApplet is not applicable for the argument (float)"

@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar May 8, 2016

Contributor

Fixed in #4440

Contributor

JakubValtar commented May 8, 2016

Fixed in #4440

@JakubValtar JakubValtar closed this May 8, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment