0

I am having a calculation problem.

main_value = 4.4789

Now i want to compare this value with a user input value

user_input = 4.5

if main_value >= user_input:
    print('yes')
else:
    print('no')

The problem is i'm displaying the main_value in single digit precision in GUI (4.4789 gets rounded and displayed_value = 4.5)

so when comparison is made the display shows 4.5 but prints NO...

how do i solve this!!!

Should i use Decimal module (please with an example) or any other simple method is there??

Thanks!!

Daniel Sampras
  • 309
  • 2
  • 18

1 Answers1

0
s[:s.index('.')+1+n]

where s is your string representing your float and n the number of digit you want to keep after the .

Paul
  • 315
  • 1
  • 9