fractions Questions
2
Solved
I have a list of fractions that I need to transform.
from fractions import Fraction
fractions_list=[Fraction(3,14),Fraction(1,7),Fraction(9,14)]
The output should be a list with the numerators fo...
Suspense asked 6/4, 2020 at 6:53
9
Solved
say we have fraction 2/4, it can be reduced to 1/2.
Is there a JavaScript function that can do the reducing?
Simpkins asked 10/1, 2011 at 22:56
13
Solved
Is there a reliable way in JavaScript to obtain the number of decimal places of an arbitrary number?
It's important to note that I'm not looking for a rounding function. I am looking for a function that returns the number of decimal places in an arbitrary number's simplified decimal representation...
Vindictive asked 2/3, 2012 at 19:53
25
Solved
Is there a range() equivalent for floats in Python?
>>> range(0.5,5,1.5)
[0, 1, 2, 3, 4]
>>> range(0.5,5,0.5)
Traceback (most recent call last):
File "<pyshell#10>", line...
3
Solved
In Python, the fractions.Fraction and decimal.Decimal standard library classes exist to help keep arithmetic with rational numbers precise. For the unfamiliar, an example of where it helps:
>&g...
Wesson asked 7/11, 2016 at 15:23
3
Solved
I'm looking for a regex to remove trailing zeros from decimal numbers. It should return the following results:
0.0002300 -> 0.00023
10.002300 -> 10.0023
100.0 -> 100
1000 -> 1000
0.0 -...
Gestapo asked 6/2, 2011 at 11:24
2
In my problem I have to write a program that calculates all the unique unit fractions (1/2 +1/3 + 1/6 = 1) that sum to one. I am currently at 570 fractions that sum to one in this format where the ...
3
Solved
I'm using the fractions module in Python v3.1 to compute the greatest common divisor. I would like to know what algorithm is used. I'm guessing the Euclidean method, but would like to be sure. The ...
Stedman asked 3/6, 2010 at 0:43
6
Given a decimal floating-point value, how can you find its fractional equivalent/approximation? For example:
as_fraction(0.1) -> 1/10
as_fraction(0.333333) -> 1/3
as_fraction(514.0/37.0) ->...
3
Solved
On my old beat-up TI-83 I can get a reduced fraction representation of a rational real number with the following syntax.
.14>Frac
7/50
Is there a similar syntax, function, or CRAN package th...
19
Solved
I'm trying to create a javascript function that can take a fraction input string such as '3/2' and convert it to decimal—either as a string '1.5' or number 1.5
function ratio(fraction) {
var frac...
Farceuse asked 22/8, 2011 at 2:37
11
Solved
I want to write fraction value such as the picture below:
How do I write fraction value using html without using image?
NOTE: I don't want this 1 1/2 pattern but strictly just as the pic above
...
3
Solved
I have matrix A and a right-hand-side vector y expressed in terms of fractions.Fraction objects:
import random, fractions, numpy as np
A = np.zeros((3, 3), dtype=fractions.Fraction)
y = np.zeros(...
Alrick asked 30/10, 2015 at 13:21
7
Solved
How can I write an algorithm that given a floating point number, and attempts to represent is as accurately as possible using a numerator and a denominator, both restricted to the range of a Java b...
Rigel asked 1/11, 2009 at 11:35
3
Solved
I try to represent a floating point number as a ratio of two integers, but for some reason the integers that I get are quite different from what I would expect to see. Can somebody explain this?
&g...
Ambulant asked 21/11, 2013 at 15:4
1
Solved
I have a web application and search is powered by ElasticSearch.
I calculate fractional values in Java using ScriptEngine :
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine eng...
Cila asked 20/1, 2022 at 5:51
12
Solved
In JavaScript, is there any way to convert a decimal number (such as 0.0002) to a fraction represented as a string (such as "2/10000")?
If a function called decimalToFraction had been written for ...
Can asked 9/2, 2013 at 1:14
6
Solved
I was wondering how to convert a decimal into a fraction in its lowest form in Python.
For example:
0.25 -> 1/4
0.5 -> 1/2
1.25 -> 5/4
3 -> 3/1
4
Solved
Let us suppose that we have a string representing a binary fraction such as:
".1"
As a decimal number this is 0.5. Is there a standard way in Python to go from such strings to a number type (whe...
7
Solved
Given two ranges of positive integers x: [1 ... n] and y: [1 ... m] and random real R from 0 to 1, I need to find the pair of elements (i,j) from x and y such that x_i / y_j is closest to R.
What ...
Vouchsafe asked 8/12, 2010 at 8:43
3
Solved
I am building a calculator and want it to automatically convert every decimal into a fraction. So if the user calculates an expression for which the answer is "0.333333...", it would return "1/3". ...
Eos asked 9/3, 2016 at 15:1
1
Solved
I am looking for an algorithm to convert a float to a rational number, such that the rational number is guaranteed to evaluate back to the original float, and the denominator is minimized.
A naive ...
Satisfy asked 7/4, 2021 at 6:0
11
Solved
I have a fraction and I want to display it neatly and nicely.
For example
4/5
would be
4
—
5
I have looked at this and while this solution is decent the problem lies in having the 4 and the 5...
Eri asked 14/12, 2012 at 12:32
15
Solved
I want the user to be able to type in a fraction like:
1/2
2 1/4
3
And convert it into its corresponding decimal, to be saved in MySQL, that way I can order by it and do other comparisons to ...
4
Solved
I want to write a function in Python 3 that converts fractions given as numerator and denominator into their string representation as decimal number, but with repeating decimal places in brackets.
...
Barmecidal asked 10/4, 2016 at 12:8
1 Next >
© 2022 - 2024 — McMap. All rights reserved.