C++ :: 32 / 64 / 80 Bit Float Conversion?
Feb 14, 2012
I am looking for a math/big num library, that allows me to convert 32/64/80 bot float numbers to string and vice versa.
Precision & accuracy is of importance here, and since this is an IEEE standard, i have high hopes that there are libraries for this out there, which would save me the hassle of trying to implement this myself...
View 1 Replies
ADVERTISEMENT
Oct 14, 2013
why does the following code output "0.000000" instead of "1.000000"?
Code:
#include <stdio.h>
int main(void) {
int x=3, y=2;
printf("3/2 is %f
", x/y);
return 0;
}
the code was compiled and run using gcc 4.4.7 and glibc 2.17 on linux kernal 2.6.32 running on a PC with an intel i5-2500k cpu(sandy bridge)
View 8 Replies
View Related
Oct 22, 2013
I want a code that can convert floating/double value into string/char array(char arr[]) and also it can be run on Boreland C++ 5.02
Here I've a code but it doesn't show all the numbers. Instead, it's showing in exponential form which I don't want!!
int main() {
char* str = new char[30];
float flt = 2.4567F;
sprintf(str, "%.4g", flt );
cout<<str<<endl; //Exponential form even after 6 digits without decimal
return 0;
}
View 5 Replies
View Related
Mar 21, 2015
So, I'm supposed to do : Create a function with unlimited number of arguments, which forms a dynamic string based on the following form (%d, %s, %f, %lf, %c), with the following prototype:
char*create(char*form, ...);
The function is supposed to have the following output:
create("Peter is %d years old and is in %s-%c class.",7,"second",'A');
-> Peter is 7 years old and is in 7-A class.
create("His GPA is %lf.",4.96);
-> His GPA is 4.96.
create("His favourite subject is math!");
-> His favourite subject is math!
I've managed to do the following :
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
char *create(char *form, ...) {
char *res =(char*)calloc(1,1),*pos_int,*pos_float,*pos_str,pos_char,*pos_long;
[Code] ....
The part with %d and %s string was not that hard, but now I'm supposed to convert %f and %lf to string, I've tried using sprintf but I've had no luck so far, another problem is the fact that I've gotta use lists to complete the task. I've been trying to convert float to string for the past 2 hours, but I'm drawing a blank now.
View 4 Replies
View Related
May 10, 2013
I would like to convert a float or double variable into unsigned char variable and back.
float number_float = 23.453f;
unsigned char* number_char = (unsigned char*)malloc(sizeof(float));
number_char = reinterpret_cast<unsigned char*> (&number_float);
float* number_float_0 = reinterpret_cast<float*>(&number_char);
I am not getting the same value back.. why?
View 2 Replies
View Related
Nov 20, 2013
I can do the folowing:
float var1 ;
var1 = 9.12345 ;
printf("%.2f",var1) ;
the output will be 9.12. What if I wanted to save that as another separate float with displaying it on screen?
View 1 Replies
View Related
Jun 8, 2014
#include <iostream>
#include <string.h>
#include <sstream>
[Code]....
View 1 Replies
View Related
Apr 9, 2014
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int displayMenu ();
void addRecords ();
void zip ();
void city ();
[Code] ...
View 11 Replies
View Related
Apr 1, 2013
I want to convert time from est to utc. Is there any function for this.
View 3 Replies
View Related
Oct 15, 2014
I am having trouble in creating a program (named "up.c") that should do the following:
- if you run the command ("up") with no arguments, it should read input from stdin and display it on stdout, converting lowercase letters to uppercase.
- if you run the command with one or more files (as arguments to the "up" command), your program should read input from each file and display it on stdout, again converting lowercase letters to uppercase.
I'm trying to create a single program that can do both of these, and handle errors gracefully. I've found that some codes work to convert the letters, but they seem overly simple and aren't giving me what I'm looking for in my program.
View 2 Replies
View Related
Feb 25, 2013
I have this project, How do I ever Convert a .Pdf file to .txt file using C++.
View 5 Replies
View Related
May 22, 2014
I'm writing a small pice of code that takes numbers and convert it to string. So that's what I got
int main() {
char letter;
char letter1;
char letter2;
cin >> letter;
cin >>letter1;
int sum = letter * 128 + letter1;
[Code] ....
Then it asks the user to enter a letter, say 'w' , which it's value is 119
Then enter another letter, say 'o' which value is 111
then it do the equation, which is take the value of the first letter multiple it by 128 then add it to the value of the second letter.
How can I make it does this process in a For loop, or any kind of loop??
Then I have the second part which is the other way around. That is when the user enter a numbers then the code convert these numbers to a string.
251394404 - "d"
1964018 - "rd"
15343 - "ord"
119 - "word"
so what's happening here is the it divide each time by 128. But I can't do that in a code.
View 3 Replies
View Related
Jun 7, 2013
I have a question on conversion between char & string. I have cut & pasted the part of the code from my C++ code and my function "decryptPwd" uses C style code with "char" etc.
I need to pass a string (mypwd) somehow to this function after conversion & then compare it to another string (newmypwd).
I tried - "decryptPwd(mypwd.c_str())==newmypwd.c_str()" but it did not work.
..
#include <string>
..
char* decryptPwd(char hash[64]);
main () {
string mypwd;
string newmypwd;
if (decryptPwd(mypwd)==newmypwd)
[Code] ...
View 7 Replies
View Related
Mar 10, 2014
Converting an IP address to a binary number? As in the entire thing 123.45.555.49 to it's binary equivalent.
View 14 Replies
View Related
Sep 12, 2014
I am trying to insert values from a form into my SQL database. Two of the fields in the SQL database are of type DateTime.
When trying to insert I am receiving the error "Conversion failed when converting date and/or time from character string."
The relevant code is as follows:
DateTime saveNow = DateTime.Now;
string sqlFormattedDate = saveNow.ToString("yyyy-MM-dd HH:mm:ss");
conn.Open();
[Code] ....
The table layout:
View 5 Replies
View Related
Jul 9, 2012
I am beginner in developing C # and I will like to develop an application that a converte. csv file (table) in an xml file
View 1 Replies
View Related
Nov 26, 2012
i have used single argument conversion function which gets called in below scenario.
Code:
#include<iostream>
using namespace std;
class Demo
{
[Code]....
It is giving error "test3.cpp: In function `int main()':test3.cpp:18: syntax error before numeric constant"
But it should work as Demo d=100; works
View 3 Replies
View Related
Jun 14, 2013
I'm trying to make OBJ converter. The file structure of which I am trying to convert is an XML structure. Here's an example. I currently have a lua script that does this for me. But it always crashes on big objects. It's for a game called "ROBLOX" The only information I need to convert is.
<int name="BrickColor">194</int> <-- Brick Color
<CoordinateFrame name="CFrame"> <-- Position
<X>0</X>
<Y>0.600000024</Y>
<Z>0</Z>
And
Vector3 name="size"> <-- Part size.
X>1000</X>
Y>1.20000005</Y>
Z>1000</Z>
Here's the lua script. [URL] .....
This currently grabs all of the ClassNames in the place and converts them to OBJ wavefront gemotry.
View 3 Replies
View Related
Jul 25, 2013
So I tried debugging this program almost 10 times, each time finding a problem then making code to fix it, I used to get wrong values but then now after I changed the calculation from an infinity while loop to a for loop (because after some changes I realized that now I know the number of entries, meaning the start and the end of the loop) the program now displays no values at all. I checked it thoroughly and until the calculation process its functioning exactly the way it should but then the calculation breaks hell loose . Also the for loop that raises 2 to the power needed works fine too so it must be something with the other processes included in the calculation....
This used to be a function of a multiple value types conversion program, I isolated it for easier analysis as a lone standing program.
Code:
#include<iostream>
using namespace std;
int main() {
int d[10],e[10],anse=1,r,limit;
short int counterd=0,i,j;
float bind=0;
[Code] ....
View 11 Replies
View Related
Mar 8, 2013
I am Getting following errors I don't know why.I have mentioned the lines (in comments) where these errors are occurring.
__________________________________________________
warning C4018: '<' : signed/unsigned mismatch
error C2064: term does not evaluate to a function taking 0 arguments
error C2064: term does not evaluate to a function taking 0 arguments
__________________________________________________ _
Code:
/////////////////////////////////////////////////
//libraries
/////////////////////////////////////////////////
#include <iostream>
#include <string>
using namespace std;
[Code] .....
View 1 Replies
View Related
Nov 3, 2013
Code:
/*Currency Conv Control Module*/
#include <stdio.h>
#include "currencyconv.h" /* defines constants, declares functions */
int main(void) {
float us_dollars;
float currency;
int user_input;
[Code] ....
This is $$ converter program I created that is split up over 3 files. It takes the users input in US Dollars and converts it to the currency selected. When executing the program I am encountering a small problem. It actually isn't converting anything and returns 0.00 dollars.
I would like for it to convert the amount entered into the currency selected. I would also like to add in the print statement the type of currency the user has selected.
View 3 Replies
View Related
Sep 16, 2013
Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#define MAX 50
[Code] ....
[URL] .....
My output should look like this ..
Enter an expression in infix form: (9+6)/(2*4)^15
Specify output expression type,1) Prefix 2)Postfix
The Prefix expression is: /+96^*2415
----------------------------------------------
Enter an expression in infix form: (9+6)/(2*4)^15
Specify output expression type,1) Prefix 2)Postfix
The Postfix expression is:96+24*15^/
View 2 Replies
View Related
Jun 15, 2013
i have given a project for currency conversion program with add,delete,search,display option. but i was thinking if it can update the currency rate from internet at beginning.
View 3 Replies
View Related
Feb 13, 2014
I did an interesting test on the type conversion between int and unsigned long. the results is like the following:
#include <iostream>
#include <limits>
using namespace std;
int main() {
int ival(-100);
unsigned long ulval1(numeric_limits<unsigned long>::max());
unsigned long ulval2(10);
[Code] ....
18446744073709551615
8
18446744073709551515
8
18446744073709551526
what I want to say is, there can be several conditions for adding a signed int to an unsigned long:
1: if the ival is positive, then adding a positive to a positive, both value should be converted to unsigned long, which is reasonable, even when the sum is larger than the max limit of unsigned long, because user himself should be ware of that the sum value may be too large and will be modulo into the range of unsigned long.
2: if the ival is negative, but the sum is positive, then both sum and ulval can fit in unsigned long, so we should convert them into unsigned long
3: if the ival is negative, and the sum is also negative, that means the ulval's real value can actually fit in int range, so the compiler should convert it to int, so as to preserve the value. but compiler didn;t do this to comply it's "preserving value" rule.
View 3 Replies
View Related
Aug 9, 2013
This program is basically working. I'm very knew to C++, so basically I need instructions as if you were explaining this to your grandma. I need this to loop but how to incorporate one. Basic code (while loops). Here is what I've done so far.
#include <iostream>
using namespace std;
int main () {
int i, c, k;
cout << "Please enter a number to convert: ";
cin >> i;
[Code] ....
View 4 Replies
View Related
Jun 3, 2013
How to convert int into string ? I had done conversion string to int.
My code :
/*Convert string into int using stringstream */
#include <iostream>
#include <string>
#include "console.h"
#include <sstream>
using namespace std;
[Code] .....
View 3 Replies
View Related