cclemon
(Student)
October 16, 2024, 5:31pm
1
I would like to set an if-then activity. When variable “today_int” is greater than “three_int”, then variable “real_answer” will be string increase.
Variable “three_int” is float (95.53)
Variable “today_int” is float (63.53)
The correct output for real_answer should be decreased. However, I use a message box to test, the box shows an increase.
Can I know how to solve this? Thank you.
postwick
(Paul Ostwick)
October 16, 2024, 5:50pm
2
You named your variables today_int and three_int and then are trying to use float values. INTegers don’t hold decimals (float values). Integers only hold whole numbers.
Are your variables defined as int? You should be using double or decimal.
cclemon
(Student)
October 16, 2024, 6:07pm
3
Hi, thank you for your reply. The variables are double.
postwick
(Paul Ostwick)
October 16, 2024, 6:41pm
5
Then I suggest putting a breakpoint on the If, run in Debug mode, and see what the value of those variables actually is.
Hi @postwick
If you can choose the double. it will work correctly.
system
(system)
Closed
October 21, 2024, 12:58pm
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.