Ask coding questions

← Back to all posts
Help with my calculator.
HuhBoi (1)

the calculator i'm working on for a school project isn't working with fractions. an invalid thing pops up that i don't understand. just want to know if there is any way to use fractions in python. Thanks!

Answered by Bunnytoes (158) [earned 5 cycles]
View Answer
Bunnytoes (158)

and if this answered your question please select it :)

HuhBoi (1)

@Bunnytoes thx for letting e know.

Bunnytoes (158)

@HuhBoi np :) happy to help. Also thanks for accepting the answer

Bunnytoes (158)

also the ** doesn't work

Bunnytoes (158)

sorry, computer languages only work with decimals

MocaCDeveloper (651)


computer languages only work with decimals.

That is not true, whatsoever. How do you think an OS has interrupt calls? Via using an integer(example the kernel interrupt call is 0x80(which is 128 in hex).

So, if your claim was truthful, that would mean all and any "integers" that you see in a programming language, ex in C, would automatically be converted to a decimal. But it's not. Why's that? Because integers and floating point numbers(decimals) exist in computer languages.

If it didn't, why would there be such a thing as type 'int' in C/C++/Go/Java etc?.

Bunnytoes (158)

@MocaCDeveloper I mean they don't have fractions, you can multiply by them ex. 5 /3 * 3 but the answer will be decimal if the answer isn't whole

Bunnytoes (158)

@MocaCDeveloper and if you use the divide on the thing, it won't be a fraction and you misunderstood what I was saying