Total members 11890 |It is currently Fri Apr 19, 2024 12:38 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





convert from type to type in C++
cpp code
/*
* Type conversion games.
*/
#include <stdio.h>

main()
{
/* Meaningless numbers. */
short s = -41;
int i = 9;
double d = 4.27;
double ld = 4983.22;
long l = 17;
long long ll = 170;
unsigned ui = 48;

/* When using printf, you must specify the size for items longer
than int or double. Many incorrect combinations work anyway,
but it's a good idea to get it right. */
printf("A: %d %ld %lld %f %lf\n", i, l, ll, d, ld);

/* Operators generally convert to the longer type, but you can
force other conversions with casts. */
printf("B: %f %d %d %f %f\n",
i * d,
i * (int)d,
i / 12,
i / 12.0,
(double)i / 12);

/* Conversion will convert to the left type. */
i = d;
d = s;
printf("C: %d %f\n", i, d);

/* Unsigned values can be printed with the u conversion. It generally
differs from %d only for large numbers. */
printf("D: %u\n", ui);

/* Constants can be appended with a letter to give them the
associated type. This generally matters only when the
constant you want won't fit into the unmodified length. */
l = 1598L;
ll = 9081092830129ll; /* Maybe LL would be better than ll. */
ld = 49.3981273394L;
printf("F: %ld %lld %.12lf\n", l, ll, ld);

/* Converting from a longer to a smaller size will also produce
junk if the value does not fit. */
i = 8000000;
s = i;
printf("G: %d == %d (sort of)\n", i, s);
}

convert from type to type in C++



_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Type Conversion
 .dll conversion     -  
 Number Conversion     -  
 please get me the following Delphi to Java conversion     -  
 SUCCESSIVE APPROXIMATION ANALOGUE TO DIGITAL CONVERSION     -  
 conversion from binary to decimal numbers as string     -  
 ramp Counter ANALOGUE TO DIGITAL CONVERSION (ADC)     -  
 Type conversions     -  
 Testing the Type of a Variable     -  
 range of data type     -  
 set MIME type in link     -  



Topic Tags

C++ Variables






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com