Anything related to converting a floating point number to and from other representations.
Questions tagged [floating-point-conversion]
290 questions
0
votes
2 answers
Faulty Function in C++
Currently I have a function in an application which takes in a float as a parameter and should perform a simple multiplication and division on the value passed in. Before the value is passed into the function in the application, it is typecast to a…

Enchanter
- 117
- 1
- 10
0
votes
0 answers
Trying to convert a Float64 into Float32 on ROS
i'm working on a project on ROS, i'm trying to pass from a visualization of a marker into a visualization of a point in a pointcloud.
the markers coordinates are rappresented in float64
the points (of pcl) coordinates are rappresented in float32
i…

JacoPisa
- 1
- 1
0
votes
1 answer
Reading lines of a float and converting to integers
Write a C program that reads lines containing floating point values of type double one per line from the standard input ( e.g. using scanf ), converts those values to integers and then prints those values as right justified integers in a…

Jobengals5
- 11
- 2
0
votes
1 answer
Java to map a range of float values to graphical display
I want to take a range of float values (subject) that change and map them on to a static range of colours 0 - 255 for displaying on the screen.
The subject range of values start with the float being a minimum of 0.056582272 to the largest 0.34371486…

Munkybunky
- 173
- 1
- 7
0
votes
2 answers
Displaying signed floats in Python
Until this month, my outdoor DHT22 temperature/humidity monitor has been working fine. However, with the cold weather, and temperatures now sub-zero, I've noticed that my routine is failing to handle negative temperatures - instead they are…
0
votes
1 answer
Check whether an input string consists out of specific characters -> Floating point Number
I am an absolute beginner in (c) programming and I have to find a solution for the following problem:
I have to parse command line arguments to floats in a struct. This works quite well using argc, argv and atof. But is there an way to check,…

ljagg
- 11
- 2
0
votes
4 answers
Convert a list of ints to a float
I am trying to convert a number stored as a list of ints to a float type. I got the number via a serial console and want to reassemble it back together into a float.
The way I would do it in C is something like this:
bit_data =…

Egor
- 401
- 1
- 7
- 14
0
votes
1 answer
Formatting a float to a certain length with Powershell
I am trying to round/ only print out floating numbers to a certain length no matter what the value is (I have a document that it needs to fit properly in). I am using powershell but I haven't found anything useful.
There can be a max of 6 digits if…

Garrett Minky
- 27
- 1
- 10
0
votes
0 answers
Turbo Pascal handle Nan and INF values in floating point variable
I've got a Turbo Pascal 5.5 program which has generated a binary data file containing Not A Number values. Using Turbo Pascal 5.5, I can import the data file correctly. But when I get an range-check error when I test
If a.aSingle > 0 then
I can, of…

david
- 2,435
- 1
- 21
- 33
0
votes
1 answer
How to test fixed point library?
I need to develop a math library using fixed point arithmetic.
I need to test this library.
For testing it, I need to do the following:
read floating point number.
Convert it into fixed point number
Do all operation using fixed point…

user966379
- 2,823
- 3
- 24
- 30
0
votes
1 answer
Can a base 10 floating-point number be converted into the equivalent base 2?
Given a base 10 floating-point number, for example, .583*10^3, can the number be converted into the equivalent base 2 form x*2^y by separately converting the fraction (.583) and the exponent (3) into base 2? If so how could I demonstrate that?…

A_Pointar
- 121
- 1
- 12
0
votes
2 answers
Safe Range of double which can be cast to float without any data loss
What is the safe range of double which can be cast to float without loosing any data (both with and without fraction part)
Example:
double value = 1423210126.00f;
float floatVal = (double)value;
//floatVal = 1423210112 if we print. There is a…

s.s
- 138
- 8
0
votes
2 answers
Wierd result in formatting float value to string using String.format
I'm kinda recent to Java.
I understand in general the issues around floating point precision and conversion but not sure why am seeing such a ridiculous result in Java...
I did this...
String str1 = String.format("%.02f", 0.001921921f);
String str2…

dangling_refrenz
- 325
- 3
- 12
0
votes
1 answer
Convert from double (GNU scientific library) to SC16Q11 in C
I'm using the GNU Scientific Library to define & use complex numbers. A complex number is defined as
typedef struct{
double dat[2];
} gsl_complex;
Which is just representing real and imaginary parts as a double-precision floating point…

user2742907
- 87
- 1
- 11
0
votes
0 answers
PHP Subtracting two numbers should return zero, but it doesn't
I have a function written in PHP that calculates account balances by subtracting all payments from all charges.
Unfortunately I have one account that is returning a value of -4.5474735088646E-13 when I subtract 2716 from 2716. I was kind of…

Vincent
- 1,741
- 23
- 35