Zenno having problems with a simple math solution

VhzD8gbfAY

Новичок
Регистрация
21.03.2015
Сообщения
4
Благодарностей
0
Баллы
1
I attached the project. 0.10 + 0.05 is appearently 0.1500000000002 for whatever reason and I have no idea why it does that or how I could truncate it down to 0.15
 

Вложения

amyboose

Client
Регистрация
21.04.2016
Сообщения
2 312
Благодарностей
1 191
Баллы
113
It's not a problem of zenoposter or c#. It's a right action for all programming languages.

use that code:
Код:
decimal res = 0.1m + 0.05m;
 

VhzD8gbfAY

Новичок
Регистрация
21.03.2015
Сообщения
4
Благодарностей
0
Баллы
1
Hi Amyboose, thanks for your reply.

Unfortunately I am not sure on what exactly that code does or where it should go.

I am still learning the basics of Java so bear with me.

I tried: decimal res = {-Variable.Variable0-}m + 0.05m ---> no result
I tried: decimal res = 0.1m + 0.05m; ---> no result

I am trying to make Zenno take the value of whatever is in the field (for example 0.10) and make it a variable so i can add 0.05 to it then add it to a different variable that will be entered in the field and then loop the whole process.
The only problem im having is this strange result. Question at this point: Is it even required to use Java for this or is there an easier solution?
 

amyboose

Client
Регистрация
21.04.2016
Сообщения
2 312
Благодарностей
1 191
Баллы
113
I don't know js and java but you should use decimal if it supported by javascript or round to near value.
So for c# you can use float:

Код:
float x = (float)0.1;
float y = (float)0.05;
float result = x + y;
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)