rational-number Questions
2
Solved
I've written a simple code:
sub euler-ex ($x) of Seq {
1, { $x**++$ / [×] 1 .. ++$ } ... Inf }
say " 5: " ~ euler-ex(5)[^20] ~ " = " ~ [+](euler-ex(5)[^20]);
The output:
5: 1 ...
Snowstorm asked 1/11, 2022 at 16:43
2
Solved
I would like to get an elegant code, which removes the insignificant closing zeroes, eg:
29.970 => 29.97
29.97 => 29.97
25.00 => 25
25.0 => 25
I tried:
argument.to_r.to_f.to_s
But...
Cavite asked 17/6, 2016 at 22:8
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
1
Solved
I'm looking for a method to convert the exact value of a floating-point number to a rational quotient of two integers, i.e. a / b, where b is not larger than a specified maximum denominator b_max. ...
Devastation asked 2/7, 2018 at 19:0
4
Solved
I'd like to test the value of an enumeration attribute of a DOORs object. How can this be done? And where can I find a DXL documentation describing basic features like this?
if (o."Progress" == 0)...
Fungistat asked 30/8, 2011 at 8:43
5
Solved
I want to display some Rational values in their decimal expansion. That is, instead of displaying 3 % 4, I would rather display 0.75. I'd like this function to be of type Int -> Rational -> S...
Brill asked 19/6, 2015 at 6:29
2
Solved
I'm using the Zarith library to do arbitrary-precision rational arithmetic. Suppose I have a rational number q of type Q.t that is the ratio of two big integers (Q is Zarith's arbitrary-precision r...
Pali asked 10/11, 2015 at 6:1
2
Solved
I want to perform operations on rational matrices. I use the modules numpy and fractions.
Here is my code:
import numpy as np
from fractions import Fraction
m=np.matrix([[Fraction(1, 6), Fractio...
Boustrophedon asked 21/3, 2015 at 11:13
8
Solved
I once got the following as an interview question:
I'm thinking of a positive integer n. Come up with an algorithm that can guess it in O(lg n) queries. Each query is a number of your choosing, an...
Dud asked 26/3, 2011 at 6:19
1
© 2022 - 2024 — McMap. All rights reserved.