Anything related to converting a floating point number to and from other representations.
Questions tagged [floating-point-conversion]
290 questions
0
votes
2 answers
How to convert floating point input to integers and preserve maximum precision?
I have to use an algorithm which expects a matrix of integers as input. The input I have is real valued, therefore I want to convert the input it to integer before passing it to the algorithm.
I though of scaling the input by a large constant and…

stressed_geek
- 2,118
- 8
- 33
- 45
0
votes
1 answer
Modulus with floating point in c
I'm getting illegal use of floating point error on compiling the following program. Please let me know where I am committing a mistake.
#include
#include
void main()
{
float a;
clrscr();
printf("\n Enter the num : ");
…

rippy
- 195
- 3
- 5
- 14
-1
votes
1 answer
How to find the mean and the variance in assembly from an unsigned integer into a floating-point number/decimal
Here is the code that I have below:
INCLUDE Irvine32.inc
.386
.model flat, stdcall
.stack 4096
ExitProcess proto, dwExitCode:dword
PWORD TYPEDEF PTR WORD
.data
RAW WORD 10, 12 , 8, 17, 9, 22, 18, 11, 23, 7, 30, 22, 19, 60, 71
ptr1 PWORD…
-1
votes
1 answer
How to use gnu gcc flag -mpc32, -mpc64 and -mpc80?
I got these GCC flags from the GNU GCC compiler Manual. But when I tried to use those flags (-mpc32, -mpc64 and -mpc80) I couldn't observe the behavior. So I need help on how to use these flags with a sample code.
sample code I tried:…

Prajwal Kumar
- 137
- 6
-1
votes
1 answer
How do I finish converting from single precision floating point to decimal?
I am converting C22E8300 from a Single Precision IEEE 754 Floating Point to a decimal.
First, I converted to binary: 1100 0010 0010 1110 1000 0011 ...
Calculated the exponent as 5. The mantissa is 0.24762
How do I finish the conversion now?

Mike Brathwaite
- 13
- 1
- 3
-1
votes
1 answer
x8086 Assembly, pushing 0.0001 onto stack becomes 9.99999.. instead of 0.0001
I am trying to implement newtons algorithm for square roots. I have included the complete C program so you can see what i am trying to do. I am trying to write the C program included below in assembly. Right now i am just trying to correctly write…

Some_Dude
- 309
- 5
- 21
-1
votes
1 answer
c float to int conversion acting weird
I'm trying to convert a float value to an int in C. I'm using print statements to see what's happening and making sure I'm getting the desired results, but something is not working correctly. Here is my code:
#include
#include…

Marc Turpin
- 19
- 1
-1
votes
2 answers
SQL Server Management Studio SSMS Convert all columns from float to nvarchar
sorry if this has been asked before in some form (I've been looking around for it but haven't found something that fits my question exactly). What I am trying to do is take all of the tables in my database and address all the columns in those…

Scott T
- 233
- 2
- 5
- 14
-1
votes
1 answer
How to get rid of 1.#J output in this code?
I was wondering how to get rid of the 1.#J output that appears when it is run. I know it is related to the float mpg variable after the trip selection part. I am just beginning to use C, so any help is greatly appreciated. Also, the program is not…

AMM24
- 7
- 1
-1
votes
1 answer
Convert a float to an int
I have a price for a car, let's say 10000. I want to apply a 20% sale to this price.
I have a struct in which auta->cena is a float.
int year, i, n=0, pocet=1, sale;
scanf(" %d", &year);
scanf(" %d", &sale);
for(i=1; i<=pocet; i++){
if(year ==…

domestos
- 7
- 4
-1
votes
2 answers
Cannot convert string to float
I am getting information from a csv, I need to take a field which in theory is a float, but can come empty, I'm this function which takes the row [i] where the float is, and should return the float,
def fun(x):
if not(x):
x=0
…

Hook
- 391
- 5
- 16
-1
votes
1 answer
floating point precision using memcpy C++
I have a tricky problem that I do not understand. I have an array of uint8_t that I need to convert to a 32 bit floating point. I am using memcpy to accomplish that...however the rounding seems to be off. Could someone please explain what is…

user2494298
- 299
- 3
- 7
- 23
-1
votes
4 answers
Illegal use of floating point in C
I kept getting Illegal use of character on the line that checks if a variable is empty or null.
Does anyone know why this happened?
the error points here:
if((fa == "" && fp == "") || (fb == "" && fp == "")){
though it worked before i just dont…

magicianiam
- 1,474
- 7
- 33
- 70
-1
votes
2 answers
Getting wrong output from a simple floating point calculation
Possible Duplicate:
C++: What is the printf() format spec for “float”?
I am absolutely new to programming, just a starter level (still very novice and error-prone :)
The question that I have is as follows. I am writing a program in C to transform…

wondersz1
- 757
- 8
- 15
-2
votes
2 answers
Float to string conversion output differs
I am trying to parse string to float but it gives me some different output.
Suppose my code :
String a = "111111111111111111111.23";
Float f = Float.parseFloat(a);
System.out.println(f);
It gives me something like: 1.1111111E20
In a simple manner,…

user3145373 ツ
- 7,858
- 6
- 43
- 62