floating-point Questions
8
It would be nice to have an equivalent of R's signif function in Ruby.
For example:
>> (11.11).signif(1)
10
>> (22.22).signif(2)
22
>> (3.333).signif(2)
3.3
>> (4.4).signi...
Bonaparte asked 5/12, 2011 at 8:24
7
Solved
How do I get python to accept both integer and float?
This is how I did it:
def aud_brl(amount,From,to):
ER = 0.42108
if amount == int:
if From.strip() == 'aud' and to.strip() == 'brl':
ab = in...
Ganesha asked 22/4, 2017 at 20:13
8
I am trying to implement my own version of pow() and sqrt() function as my custom library doesn't have pow()/sqrt() floating point support.
Can anyone help?
Logos asked 18/4, 2010 at 23:39
3
I use a Fortran 90 model under Ubuntu 14.04. The gfortran 95 compiler (gfortran 4:4.8.2-1ubuntu6) and the gcc 4:4.8.2-1ubuntu6 are installed by Ubuntu Software Center. After I ran the model I get t...
Margueritamarguerite asked 17/2, 2015 at 8:51
16
Solved
How do I generate random floats in C++?
I thought I could take the integer rand and divide it by something, would that be adequate enough?
Auberge asked 26/3, 2009 at 15:49
5
Solved
Even though Lua does not differentiate between floating point numbers and integers, there are some cases when you want to use integers. What is the best way to covert a number to an integer if you ...
Crick asked 11/3, 2012 at 11:24
4
Solved
In my question about Analysis of float/double precision in 32 decimal digits, one answer said to take a look at __float128.
I used it and the compiler could find it, but I can not print it, since ...
Complexity asked 14/5, 2014 at 12:25
6
Solved
For some machine control in python, I write the results to a text-file, that someone else can copy into Excel (this is the most convenient way in this situation). However, in the Netherlands, Excel...
Melodic asked 27/3, 2019 at 14:30
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
5
Solved
I have an array of Floats that need to be converted to a byte array and back to a float[]... can anyone help me do this correctly?
I'm working with the bitConverter class and found myself stuck t...
Lim asked 8/1, 2011 at 19:45
11
A single/double/extended-precision floating-point representation of Pi is accurate up to how many decimal places?
Sipe asked 3/2, 2009 at 16:24
9
Solved
Is there a way to get the float value of a string like this: 75,25 €, other than parsefloat(str_replace(',', '.', $var))?
I want this to be dependent on the current site language, and sometimes t...
Encyclopedist asked 28/2, 2011 at 8:48
25
Solved
I am trying to divide two image widths in a Bash script, but bash gives me 0 as the result:
RESULT=$(($IMG_WIDTH/$IMG2_WIDTH))
I did study the Bash guide and I know I should use bc, in all examp...
Puppetry asked 4/10, 2012 at 7:16
9
Solved
I have a floating point number that I want to truncate to 3 places but I don't want to round up.
For example, convert 1.0155555555555555 to 1.015 (not 1.016).
How would I go about doing this in ...
Lyndy asked 12/11, 2011 at 18:43
3
Solved
I have a float value: 12345.6489
When I format this using:
(12345.6489f).ToString("F1")
Then I get a result of
12345.7
But this is incorrect, since it should be 12345.6.
Does anyone understan...
Liquidize asked 14/1, 2013 at 19:27
7
Solved
Hello I have this code in C#:
float n = 2.99499989f;
MessageBox.Show("n = " + n.ToString("f2", CultureInfo.InvariantCulture));
And this code in C++:
float n = 2.99499989f;
printf("n = %.2f", n)...
Paunch asked 18/1, 2010 at 10:58
5
Solved
It seems to me that the code
console.log(1 / 0)
should return NaN, but instead it returns Infinity. However this code:
console.log(0 / 0)
does return NaN. Can someone help me to...
Horde asked 16/9, 2013 at 22:23
4
Solved
I use "g" for formatting floating point values, but it switches to scientific formatting too soon for me - at the 5th digit:
>>> format(0.0001, "g")
'0.0001'
>>> format(0.00001, ...
Stockyard asked 7/1, 2011 at 14:16
4
I want to check that a given double/float variable has the actual bit pattern 0x0. Don't ask why, it's used in a function in Qt (qIsNull()) that I'd like to be constexpr.
The original code used a ...
Esqueda asked 17/2, 2012 at 12:31
3
Solved
I'm using python 3.2.2 on windows 7 and I'm trying to create a program which accepts 7 numbers and then tells the user how many are positive, how many are negative and how many are zero. This is wh...
Paste asked 14/11, 2011 at 10:10
3
Solved
Whenever I search for the term 'denormal numbers' or 'denormals', I only find ways how to detect them and round them to zero. Apparently, nobody really likes them, because dealing with them incurs ...
Tarrance asked 14/5, 2012 at 12:27
2
Solved
What is the idiomatic way to go Double -> Float?
Is it uncurry encodeFloat . decodeFloat ?
(I am using gloss, this requires Floats)
And what is the recommended way to find an answer to such q...
Brambling asked 4/5, 2015 at 11:52
2
Solved
I have been looking at some code which had a weird optimisation fault and, in the process, stumbled upon a fault condition in strtod(), which has a different behaviour to strtof(), right on the edg...
Blackbird asked 19/1, 2024 at 16:28
39
Solved
I would like to format my numbers to always display 2 decimal places, rounding where applicable.
Examples:
number display
------ -------
1 1.00
1.341 1.34
1.345 1.35
I have been using this:
p...
Stratigraphy asked 26/5, 2011 at 5:22
31
Solved
How does one round a number UP in Python?
I tried round(number) but it rounds the number down. Here is an example:
round(2.3) = 2.0
and not 3, as I would like.
Then I tried int(number + .5) but i...
Floriaflorian asked 1/3, 2010 at 14:40
© 2022 - 2025 — McMap. All rights reserved.