815 questions
1
vote
1
answer
126
views
Delphi EncodeDateTime and EncodeTime Time portions are different
Here is an example which demonstrates the problem:
var
fdt, fndt : Double;
dt, dt2 : TDateTime;
begin
dt := EncodeDateTime(2023, 12, 31, //
20, 10, 5, 100);
dt2 := EncodeTime(20, ...
0
votes
1
answer
46
views
fraction not display instead down a line
I am using Visual Studio 2022 I tried to display on the screen a fraction in math the code is
"\frac{ 2}{ 6}" but the vs2022 color only the "\f"
and instead of writing a fraction ...
-1
votes
1
answer
88
views
Is there a way to simplify a fraction including decimals? [duplicate]
Whenever a user inputs a fraction, it might be contain decimals (long double). I have some code (C++) below to show how I implement this:
class Fraction
{
public:
long double numerator, ...
1
vote
0
answers
27
views
SKU in Woocommerce displays the text 1/4 as a fraction
We have a Variation SKU: W-250-1/4 (the 1/4 represents lifting speed) however Woocommerce convert the text to a fraction please see Image 1 (shows Variable SKU):
and Image 2 how it is displayed:
The ...
0
votes
0
answers
24
views
How to represent fraction text value like ⅑ but with a straight divider like given in the image?
I am using fabric js textbox and on a click of a button a fraction string gets added to the textbox, Currently as a workaround I'm showing fractions like ⅑ but I have to represent the fractions with a ...
1
vote
1
answer
61
views
Issues in computing matrix numerical terms. Is Julia wrong in evaluating the result?
I have troubles in evaluating terms of a matrix nxn, where, starting with the first 3 rows, I compute the rest of the matrix with an algorithm which have a quite complicated loop. I'm trying to write ...
2
votes
0
answers
173
views
How to correct the conversion of decimal numbers to simplified fractions using the Euclidean algorithm? [closed]
I am attempting to implement an algorithm to convert decimal numbers into simplified fractions in C. To achieve this, I am using the decimal_to_fraction function which utilizes the Euclidean algorithm ...
1
vote
5
answers
135
views
What would be the most efficient way to encode a simple fraction on 32 or 64 bits? [closed]
What would be the best way to encode a positive simple fraction on 32 bits or 64 bits?
For casual binary fraction, we already have a well defined standard for floats and doubles.
In case of 32 bits, ...
2
votes
1
answer
108
views
Continued fractions in manim
I'm new to using manim and I try to implement a simple animation for a continued fraction expansion of a fraction. My code so far is as follows:
from manim import *
class Eq(Scene):
def construct(...
0
votes
0
answers
27
views
Alternatives to fractional types
I have an application in which, it seems to me, fractional types are essential. And I think the use case is quite common.
Yet though they are implemented in several languages, I have not seen any ...
0
votes
2
answers
63
views
CSS Grid: What is the difference between fraction vs percentage?
How are the fractions different to percentage? Is there any difference in the below codes?
grid-template-columns: 1fr 1fr 1fr 1fr;
/* --------vs-----------*/
grid-template-columns: 25% 25% 25% 25%;
...
0
votes
0
answers
15
views
How can we sort array after fraction of 2 arrays (Fractionak Knapsack)
This is Fractional Knapsack problem which I am trying to solve. I have tried this index method to get max index each time but it is taking the same max index after 2nd iteration of loop, please help ...
-1
votes
3
answers
524
views
How to Generate a Random Fraction Within a Specific Range
In my project, I built my own Fraction:
public partial struct Fraction
{
public double Numerator;
public double Denominator;
public readonly decimal Quotient
{
get
{
...
0
votes
3
answers
121
views
Converting inputted fractions into decimals
I'm a python beginner, and I'm trying to create a simple triangle calculator. Right now, I'm trying to have an inputted fraction be turned into a float so that I can multiply it by math.pi and do what ...
0
votes
0
answers
11
views
finding /obtaining a "half equation" to a mathematical problem / expression
I am trying to figure out a software program I can use that will give me the full decimal numbers in the half equation in expression thaty have long , repeating decimals that get shortened in almost ...
0
votes
1
answer
107
views
How to display my result in fraction form instead of decimal form when converting from degree to radians
I used the math.js library to be able to create a calculator which converts any number from radian to degree or vice versa. The calculations work perfectly, but the problem comes when trying to ...
2
votes
2
answers
113
views
How can I loop based on remainders, percentages, or floating point values?
My assignment asks me to take a data set in the form of different integers, and run them through a method that will print the appropriate number of characters to create a horizontal bar graph.
The ...
2
votes
3
answers
157
views
Assigning binary fraction to float variable in C
I am trying to do something like as below
#include <stdio.h>
int main() {
float a = 0b00000100;
float b = 0b0.0110; // this line is not working
printf("The value of first float ...
1
vote
1
answer
74
views
Why is the haskell function not working correctly?
I am wondering which mistake the following Haskellcode has!
f :: Fractional a => a -> a -> a
f x y
| x > y = x - y
| otherwise = x + y
call = f 3.5 2.0
I was trying to solve the problem ...
1
vote
1
answer
121
views
I don't get results doing partial fractions in scilab
I'm starting with scilab.
I can't do partial fractions.
How can I solve that?
this is my code:
Thanks in advance
num = 22801+4406.18*%s + 382.37*%s^2 + 21.02*%s^3;
den = 22952.25 + 4117.77*%s + 490.63*...
0
votes
0
answers
126
views
Combining integer and float parts of a number in C++
I have three variables
uint_8 a = The integer value lets say 11111100,
uint_4 b = The fractional part of a. lets say .1001,
float c
where a is 8 bits and b is 4 bits.
Is there anyway that I ...
1
vote
0
answers
50
views
Minimize rational-linear fraction function efficiently
I need to find minimum positive value of this function, where a_i and b_i are real constants and all s_i are equal to plus or minus one:
I can make it in ~n*2^n operations by brute force complete ...
0
votes
1
answer
578
views
How to convert inches with decimals to feet and inches
I have an Excel spreadsheet with the following data in A1 and A2(column is formatted as Text).
A
1 258.1875
2 294.1875
I need the data to display in B1 and B2 in feet and inches, like this: (column ...
0
votes
1
answer
478
views
Convert a text field to a decimal number field in power bi
I want to convert a column that appears to me as text that contains numbers with a decimal point to a field that will be a normal number so that I can sum up the column.
Columns that appeared to me as ...
0
votes
1
answer
73
views
How to enter a fraction with two digits in denominator
Does anyone know a way I can put in 9/10 or similar without getting the "Not a real value text"?
It works fine with single digits like 3/4, 2/5 but if I put in 2/10 I get the error.
while ...
-1
votes
1
answer
59
views
Console readline fractional number
Why with
double number = double.Parse(Console.ReadLine());
Console.WriteLine($"{number:0.00}");
or
double number = double.Parse(Console.ReadLine());
Console.WriteLine("{0:0.00}", ...
1
vote
1
answer
102
views
How to convert decimal values to fractions in a list of expressions in Python?
import sympy as sp
from fractions import Fraction
M = sp.symbols('M')
diffs = [None, 0, 5*M/2 - 3.5, 0.5 - 3*M/2, -M, M/2 - 1.5, 0, 1.5 - 3*M/2]
#Convert terms of expression to fractions (none of ...
0
votes
2
answers
78
views
Loss of precision in calculations involving fractions and floating-point numbers in Python
import sympy as sp
from fractions import Fraction
new_matrix_aux = [['X', 'B', 'X1', 'X2', 'X3', 'X4', 'X5', 'U1', 'U2'],
['X2', 10/3, 0, 1, 2/3, 1/3, -2/3, -1/3, 2/3], ...
0
votes
2
answers
540
views
JS fractions for big numbers with no precision lose [closed]
Big numbers with fraction support:
I want to perform math operation with no precision loss.
How can I do it using JavaScript?
First I tried decimal.js, but it does not preserve precision as you see in ...
0
votes
1
answer
273
views
Fractions and formats in Excel
I can convert Decimal to Fractions in Excel.
i.e. 1.25 to 1 1/4
However, I want it to appear in the format 1¼ with the fraction in superscript and subscript format.
Is there a VB code for doing this?
...
0
votes
2
answers
818
views
How to print out whole numbers alongside fractions in Python using fraction import
Im trying to print out a whole numbers alongside rational fractions
E.g: 3 1/2 , **not **7/2
I wanted to try to use if statements like
if num1 >= den1: whole +=
though i was afraid that wasnt ...
10
votes
2
answers
564
views
How to find the maximum number of unique unit fractions that sum up to one
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 ...
0
votes
1
answer
66
views
Converting a BigNum (binary w/ repeating digits) to decimal
I currently have a big-num implementation based on rational numbers (with repeating digits) that stores the following (in binary):
Integer part
Fraction part
Repeating fraction part
Some examples (...
0
votes
2
answers
72
views
How to display properly monomial in python with sympy
I've an expression that after simplify method looks like this:
5*y**3/2
I would like to see expression in this view:
(5/2) * y ** 3
but I have no idea how to do this.
Thanks in advance.
0
votes
2
answers
63
views
what is the difference between the Fraction class constructor and from_float in Python
I am using the class constructor Fraction to create fractions.
What is the difference between using the Fraction class constructor and from_float method when creating fractions from floating-point ...
1
vote
0
answers
62
views
Cancel common factors from two polynomials without merging them into a ration function expression
I'd like to cancel a rational function f1(z)=p1(z)/q1(z) given by two polynomial expressions p1,q1.
An almost complete solution would be the following
import sympy as sp
z = sp.symbols('z')
p1 = z**2 -...
1
vote
1
answer
63
views
JavaScript: Show decimals in fraction format
I want to make a ml to oz converter and present the remaining decimal in fraction formats 1/2, 1/3, 2/3, etc... As example 50 ml would be 1 2/3 oz. The integer is on the left side, and the decimal on ...
0
votes
1
answer
82
views
Incorrect multiplication of long fractions in different C++ compilers
A program takes two long fractions, and performs addition, subtraction, multiplication and comparison operations on them. In the standard CLion compiler (MinGW) the code is executed correctly, but in ...
0
votes
1
answer
102
views
signed fractional multiplication using q(4,20)
I am doing a simple test to understand signed fractional multiplication in ordinary format
and in Q(4,20) format (https://en.wikipedia.org/wiki/Q_(number_format)). I am using the fxpmath library (...
0
votes
1
answer
60
views
Fractional multiplications - unexpected results of positive numbers [duplicate]
I am getting unexpected results when multiplying 2 fractional numbers.
If i use a calculator (google) to check my sums, i get the correct answer (or the answer i am expecting)
This is an example of ...
0
votes
1
answer
52
views
I want to convert fractions of a binary into a decimal fraction, but my program keeps on giving wrong output
The formula for solving binary point into decimal point is... if 10.110 then: 1x10\*\*-1, 1x10\*\*-2, ...
but my code is so messed idk... The output of this should be .75
string a = "10....
0
votes
1
answer
153
views
Fastest way to instantiate a pair of integer values in Kotlin to use as a fraction
Motivation
I need to instance fractions in my code without the rounding error of floating point values. Therefore, I decided to use a pair of integer values, one for numerator and the other one for ...
2
votes
1
answer
873
views
Compute Bernoulli numbers with Python recursive program
I'm trying to solve a problem about Bernoulli numbers using Python. The aim is to output the numerator and the denominator of the $n$-th Bernoulli number. I use the conventions and the generic formula ...
3
votes
1
answer
252
views
How to convert incredibly long decimals to fractions and back with high precision
I'm trying to convert very large integers to decimals, then convert those decimals to Fractions, and then convert the Fraction back to a decimal. I'm using the fractions and decimal packages to try ...
0
votes
1
answer
530
views
What is the most efficient way to get denominator and numerator from decimal/fractional number
I want to get numerator and denominator from decimal and then simplify both numerator and denominator. For example, if decimal is 0.05, then numerator and denominator should be 1/20. Preferably ...
1
vote
1
answer
879
views
CDO regridding and calculating grid fractions
I have a global IGBP land use dataset in which the land cover exists out of forest cover (depicted with a '1') and non-forest cover (depicted with a '0'), hence, each land grid cell has either the ...
0
votes
2
answers
153
views
How to factorize fraction by a given symbol?
I have the following fraction:
import sympy as sp
a = sp.Symbol("a")
b = sp.Symbol("b")
a/(a+b)
And would like to print it as
1/(1+b/a)
I saw sympy had a factor function but I ...
-2
votes
1
answer
172
views
Read "fractions" from .txt file and add them using C
I'm trying to read "fractions" from a .txt file and store them in an array to later perform the sum and then simplify the result.
Fractions in the text file are represented as follows(...
0
votes
2
answers
76
views
unprecise math in R when dealing with infinite fractions
The deviations of the mean should always sum up to 0.
However, when the mean has a lot of digits, maybe infinitely like this one which is 20/7, R fails to calculate it.
x <- c(1,2,2,3,3,4,5)
sum(x -...
0
votes
1
answer
473
views
Number formating fraction in Python
I'm used to formatting fractions in Google Sheets as '# ##/##', is there any way to do the same in Python or do I have to program it?
I have tried:
F'Value: {Fraction(a / b).limit_denominator()}'
...