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

Using a dot, ., at the end for defining a float number doesn't always work #22308

Closed
iagobaapellaniz opened this issue Jun 9, 2017 · 1 comment

Comments

@iagobaapellaniz
Copy link
Contributor

iagobaapellaniz commented Jun 9, 2017

It is usual to me to convert an integer using a dot at the end, e.g., 4 as integer and 4. as a float point number.
When some operator is next to the dot it doesn't belong anymore to the number but to the operator. I haven't seen this reported, so here it goes an example

julia> 1+2 # It gives an Int as expected
3 
julia> 1+2. # This way we obtain a Float
3.0
julia> 1.+2 # It is somehow inconsistent with the above use of the dot since we obtain an Int
3
julia> 1. +2 # A space solves it.
3.0

I would propose for the dot to belong to the digit.

Just to give a use case where special care must be taken, at least from my perspective

julia> function foo(x)
       x^20
       end
julia> foo(20)
-2101438300051996672
julia> foo(20.)
1.048576e26

whereas if one goes directly to the exponent and writes 20^20 and 20.^20, they are both equally wrong.

@iagobaapellaniz iagobaapellaniz changed the title Using the dot, ., for ensuring a float number doesn't always work Using a dot, ., at the end for defining a float number doesn't always work Jun 9, 2017
@yuyichao
Copy link
Contributor

yuyichao commented Jun 9, 2017

Dup of #19089

@yuyichao yuyichao closed this as completed Jun 9, 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

No branches or pull requests

2 participants