Questions tagged [fractions]

Fractions, or "fractional numbers" (lit. "broken numbers"), or "rational numbers", are numbers expressed as the ratio of two integers, such as 1/2 or 23/17.

In computing and programming, fractional (or "rational") numbers are an alternative to floating point numbers: Since numerator and denominator are stored as integers, the representation is exact, as opposed to most floating point implementations, which cannot represent most rational numbers exactly. Arbitrary-precision ("bignum") libraries usually contain support for rational numbers.

800 questions
-4
votes
3 answers

Convert Decimal to Fraction Form method (Java)

I can't seem to find a simple method that converts a decimal value to fraction form. I need this method for use in a larger program, so the method should be passed a double value and return a string. EDIT: sorry, new here. I just wanted an idea…
akhg2235
  • 7
  • 1
  • 6
-4
votes
1 answer

Variables incorrect; fraction calculator; JAVA

I have my code here which i have posted on here before and have been helped before. The variables seem to be incorrect and i am unsure why. I entered the fraction 1/2 + 3/4 and am getting the answer 8/4. i know it has to do with the variables…
diy900
  • 1
  • 2
-4
votes
1 answer

Is it possible to do the Kattis "Mixed Fractions Q" in C and under the 2 second limit

Basically i've attempted to answer this question from Kattis: https://open.kattis.com/problems/mixedfractions I have a working solution however it goes over the allocated 2 second time limit for computation. My question is essentially, is it even…
-6
votes
1 answer

How to convert fraction into floating point number in Android?

Hello I have a really simple qestion, in my app I have an EditText and what I would like for instance is this: If I write 1/2 I would like 0.5 in the field. How can I do this?
-7
votes
2 answers

C# BigInteger remainder as fraction

Before you read, please be aware that I'm aware of the differences between integer and floating-point division, and I'm aware of how BigInteger.DivRem and BigInteger.Divide. Consider the following code examples: BigInteger a = new(5); BigInteger b =…
Matthew Layton
  • 39,871
  • 52
  • 185
  • 313
1 2 3
53
54