Menu

#1103 Decimal bug in Geany 1.24.1

v1.24.1
closed-invalid
nobody
v1.24.1
5
2015-06-27
2015-06-27
No

Using Ubuntu 14.04 with python3.4.
Noticed that Geany 1.24.1 gives wrong decimals when I try to execute a script.
Wrote a very simple program (test.py):
print(float(30/8))

In Geany the answer was 3.0 but if I write in terminal:
python3.4 test.py the answer was 3.75.
Tried this on my other computer and it showed the same error.
So either both my computers are defect or this is a bug.

1 Attachments

Discussion

  • Colomban Wendling

    The default Geany configuration uses python which is very likely to be linked to Python 2.x on your system.
    And the behavior is perfectly correct with Python 2, as the operator / will perform an Euclidean division when operating on integers. For Python 2 to give the result you want, you'd need something like print(float(30)/8).

    However you can easily configure your Geany to explicitly use Python 3.x, go to Build → Set build commands and replace the occurrences of python with python3 (in Execute and Compile).

     
  • Colomban Wendling

    • status: open --> closed-invalid
     

Log in to post a comment.