# That's lua! :( -> Prozent Bug!

I made a math project, and want to have prozent, and after I clicked `50 % 40 =`, and I expected 20 because 50 prozent from 40 is 20 but he answered 40.0 - Is there any way to leave the calculator the real prozent and why 50%40 ~= 20?? WHY??? Thank you for answering!

``````    print(50%40)
``````

returns 10, as it should.

The `%` operator is for modulus, not percentages. If you want to get 50% of 40, use `0.5 * 40`.

The `%` is the rest of division, not the percentage

@TokOut 50 % 40 isn’t 50 percent of 40. % is a module division which give you the remainder of 50 divided by 40 which is 10. So 50 % 40 is 50 divided by 40 which is 1 with a remainder of 10. Again, if you READ the reference it will tell you these things.

And as @dave1707 said ‘we are not here to teach you’

Isn’t any formule instead of `50 % 40` doing `50% * 40` or something like this

this is embarassing… Think a little about it and you’ll get a very simple formula.

If `number2 % number` is false then is `(number2/100) * number` true, right?

Because if `50%40` returns 10 then `(50/100)*40 returns 20` - IT SHOULD WORK, I go to test

Good job! You see you could find it yourself.

The mod - mode at the calculator is bugging with this code

``````        answernumber = number2/number
txt.value = txt.balue .. " = " .. answernumber
``````

But can you please help me this code, he insults this into an error why? Thanks for the help! I tried since yesterday to solve the code. Because `6 mod 5 = 1` and
`6 : 5 = 1 R1` - he insults and arithmetic error, but with `div` he is making all nice:
`100 : 8 = 12 R4` and `100 div 8 = 12` and in div instead `answernumber - math.ceil(answernumber)` I had `math.ceil(answernumber)`

@TokOut if you tap an error that you get in the console, it will be copied to the pasteboard. Then you can paste it in the forum, so that people can see what error you are getting.

Functionality:147: attempt to concatenate a nil value (field ‘balue’)
stack traceback:
Main:98: in field ‘action’
Button:64: in method ‘touched’
Main:215: in function ‘touched’

Solved, I didn’t see that I use `txt.balue` instead `txt.value`

@TokOut It’s the same thing over and over. You keep asking us to solve your problem when you’re being told exactly what’s wrong. The error message tells you exactly what your problem is. You’re trying to concatenate a nil value to something else. The variable `balue` is nil. Look at your code and see why you’re not moving something to `balue` before you’re using it.

That’s not the meaning of my calculator. Just download it with `https://gist.github.com/TokOut/b540d05e60bb49c644d8` and something with `http.request` and try it yourself

@TokOut - what dave1707 is saying, is that you need to learn to debug your own code, and he is trying to show you how to do it.

We can’t solve every simple little problem for you.

Ok