8,368 questions
3
votes
2
answers
216
views
C treating variable declared to be a double as an int
I am trying to solve a problem posed in this question which asks that a program be written that calculates logarithms of numbers without including <math.h>.
I wrote the following program:
#...
4
votes
5
answers
243
views
What is the alternative to declare a Variable-Length array in C, that may exceed Stack size, without the need of Dynamic Memory allocation?
I have the following code snippet in C that declares multiple one-dimensional and two-dimensional arrays of type double.
double func(double alphas[], double betas[], double rhos[], double **X, ...
2
votes
0
answers
77
views
GNU Octave not assigning closest double to a number literal - Can you reproduce? Is it a bug? [closed]
In GNU Octave 10.2.0, when I run x = 1.000444, I seem not to get the closest double to the real number 1.000444. Not even tied:
>> format long
>> x = 1.000444
x = 1....
4
votes
2
answers
161
views
Why do floating-point numbers print without decimal unless std::fixed and std::setprecision are used?
I'm experimenting with floating-point output in C++. I have a simple calculation which is 1359270 / 4, in a calculator this results in 339817.5, but when I print it in C++ using std::cout, I get ...
6
votes
1
answer
244
views
Speeding up integer division with doubles
I have a fixed-point math-heavy project and I was looking to speed up integer divisions. I tested double division with SSE4 and AVX2 and got nearly 2x speedup versus scalar integer division. I wonder ...
0
votes
0
answers
17
views
Double xlook up
I want to double look up where i look up the sku and col header and get the value.
The image here shows me looking up the sku and then finding the description value
"=XLOOKUP(A4,$A$20:$A$26,...
0
votes
1
answer
111
views
Scenarios where C returns maximum double value [closed]
I wrote a C function which returns a double value which in certain cases is returning the value
...
0
votes
0
answers
43
views
Flutter decimal / fractions madness [duplicate]
I wonder how people handle Flutters "decimal madness" in num/double?
Recently I implemented an app with currency / small-currency.
Small currency is 100 times larger than it original value.
...
1
vote
1
answer
86
views
Separate the integer part from the decimal part of a real number entered from the keyboard in Java
I have this code that separates the integer part from the decimal part
import java.io.*;
import java.util.Scanner;
public class hoja1ej9
{
public static void main(String[] args)
{
...
0
votes
1
answer
57
views
How to enter double and string alternately in an infinite loop? [duplicate]
I'm trying to write a calculator In Java, but I don't understand how to provide infinite input of double and string in turn. It keeps throwing InputMismatchException, I don't know what to do.
public ...
5
votes
1
answer
160
views
Haskell's double behaviour
It's a known fact that numbers like Double which correspond to IEEE 754 floating-point cannot represent numbers like 0.1 accurately.
But when I played around with it in REPL, I'm confused by the ...
-1
votes
2
answers
74
views
How to know which numbers after . are non trailing zeros
I have, for example, 123.54054000. I want a function that returns 5, which is the number of decimals that I shouldn't ignore. I want to remove trailing zeros in my app.
Examples:
For 1.010 returns 2
...
2
votes
1
answer
208
views
Why does Math.pow(10, -4) produce different results in JavaScript and C#?
I noticed that the result of Math.pow(10, -4) differs between JavaScript and C#.
JavaScript Math.pow
C# Math.Pow
In JavaScript, it seems the result is expressed as an approximation, possibly due to ...
4
votes
0
answers
62
views
Python - MariaDB result of query is rounded down
When getting data out of my MariaDB database, I lose some precision --> every number is rounded down.
stored data as seen by DBeaver:
(see atached picture)
or
1737210600 0.0911
1737209700 0.103
...
2
votes
0
answers
160
views
Discrepancy in java.text.DecimalFormat.format using pattern "###0.00%" [duplicate]
I am using the pattern ###0.00% to format percentage values.
From the documentation, it is mentioned that java.text.DecimalFormat uses HALF_EVEN rounding mode.
DecimalFormat df = new DecimalFormat(&...