This is the talk page for discussing improvements to the Type conversion article. This is not a forum for general discussion of the subject of the article.
This article is within the scope of WikiProject Computer science, a collaborative effort to improve the coverage of Computer science related articles on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.Computer scienceWikipedia:WikiProject Computer scienceTemplate:WikiProject Computer scienceComputer science
This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.ComputingWikipedia:WikiProject ComputingTemplate:WikiProject ComputingComputing
Latest comment: 13 years ago18 comments17 people in discussion
This article is off topic. Most of it is not "Type conversion" but "tutorial to C/C++ cast operation".
I did some to improve (see history) but I would ask the C/C++ advocates to consider two things:
tutorials belong to wikibooks.
that there are other programming languages where "Type conversion" has a more broader meaning.
and maybe improve the C/C++ chapter.
You are right in that the current article is not good at all. But we need to remember that C++ has quite complex type conversion system, compared with others. The problem is the shortcoming, which is not intentionally done by C/C++ advocates but is mere result of lack of contributions so far. If you think the article goes too deep, take a look at LR parser and the like. -- Taku 04:27, Nov 30, 2004 (UTC)
Did you read my Ada article? C++ is not the only language with a complex type conversion system. And of corse is should be described in wiki. The question I was trying to raise was "wikipedia vs wikibooks". How much of C/C++ cast need to be described in wikipedia "The Free Encyclopedia" and what should better moved to wikibooks "Think Free. Learn Free". --Krischik 09:43, 30 Nov 2004 (UTC)
I support the idea of a merger between "typecasting" and "type conversion". I was searching for dynamic_cast<>. The first link I took brought me to "typecasting". However, I found the explanation on "type conversion". --Kriti 05:24, 24 Aug 2005(UTC)
I am looking for a way to convert a string to integer when you know the string character is a number like 7. --Mrja84 20:14, 11 Oct 2005(ESDT)
Of course, this depends on the language and primitives you want to use. But since you're asking, the answer could be *string - '0'. --TuukkaH14:45, 12 October 2005 (UTC)Reply
I find this quite confusing, I have to say. Type conversion and type casting are very different things. Type casting being making the compiler think that something is a different type, and type conversion actually turning one type into another, in some fashion, say using atoi, in C or Integer.parseInt in Java. K.
It seems like the sections related to Eiffel are much larger than they should be, given the relative level of popularity of Eiffel. It would be more useful to show type conversion in other languages instead of so much on a fairly obscure language. In my opinion the long discourse of Eiffel's type conversion should go on an Eiffel page, or better yet, a new page.
Smithderek2000 (talk) —Preceding undated comment added 00:04, 22 September 2012 (UTC)Reply
Inaccuracies
The section on implicit type conversion contained false and misleading statements:
"For example, in the above comparisons, there would be a loss of information in a conversion from type double to type int if the value of d is larger than i can hold."
False. The comparisons listed do not involve any conversion from double to int, but the other way around. Actually, any comparison involving a double and an int will have the int promoted to double, not the other way around.
Conversely, converting from an integral representation to a floating-point one can also lose precision, as floating-point representations are generally not capable of holding integer values precisely.
Inaccurate. What is true is that a floating-point representation of n bits can never hold all integer values of n bits precisely, since there's just not enough room for both the exponent and the significand. However, an IEEE 754 double precision type is capable of representing all 32-bit integer values exactly, for example, so this statement is misleading, especially in the given context. 82.95.254.24918:12, 29 March 2007 (UTC)Reply
32 bit to double can't lose precision but 64 bit to double or 32 bit to float can but i agree that section needs a rewrite. Plugwash01:19, 31 March 2007 (UTC)Reply
"...the fractional components of the floating-point values will be truncated (rounded down)."
Those aren't the same thing. For negative numbers, rounding down means going to the next lower integer (ie floor), while truncating means removing the fractional part. 76.118.217.245 (talk) 19:28, 3 February 2008 (UTC)Reply
Another inaccuracy: the claim is made that the C code is legal as shown. In fact, the behaviour of the code is undefined (because indeterminate values are evaluated), making the conclusions spurious. —Preceding unsigned comment added by 81.154.245.15 (talk) 15:10, 15 October 2008 (UTC)Reply
There's an inaccuracy in this part: "long int to int causes dropping of excess higher order bits." That's only true if long int is a different size than int. In DOS environments, int is typically 16-bit and long int 32, and in some 64-bit environments int is 32 and long is 64. In those cases, the statement holds. However, in many 32-bit environments and some 64-bit environments, int is the same as long int at 32 bits or 64 bits (respectively), making that statement unreliable. Is there a better way of saying that, that we could include in the text? Renegrade (talk) 03:49, 21 October 2011 (UTC)Reply
Should be merged to an article on C++ casting operators (or C++ operators), if there is and should be such an article. If I find one I'll update that merge tag. — The Storm Surfer22:58, 29 August 2007 (UTC)Reply
static_cast was an individual article, then without discussion and reasons given was changed to redirect to this article. I reverted the static_cast article back to its content before redirection. --Abdull (talk) 21:39, 1 October 2010 (UTC)Reply
I also disagree, to me, atoi and related _functions_ are not even type conversion. (Type here being the concept of type as used by compilers). They are simply utility functions that take a string as an input and return an integer (e.g. atoi). There is absolutely no relation between the input passed in and the output generated, other than we hope that they in some way refer to the same value, but that depends on how we interpret that value (what I mean is that there is some form of implicit 'format convention' necessary, as to how numbers can be represented as text. —Preceding unsigned comment added by 123.27.219.212 (talk) 12:39, 23 February 2010 (UTC)Reply
Conversion vs Casting
Latest comment: 11 years ago3 comments3 people in discussion
In languages like Pascal (programming language) conversion and casting are distinctly different concepts. This article takes a rather C-centric view.
Conversion refers to either implicitly or explicitly changing a value from one data type to another, e.g. a 16-bit integer to a 32-bit integer. The storage requirements may change as a result of the conversion. A loss of precision or truncation may also occur.
Casting refers to explicitly changing the interpretation of the bit pattern representing a value from one type to another. For example 32 contiguous bits may be treated as an array of 32 booleans, a two character Unicode string, an unsigned 32-bit integer or an IEEE single precision floating point value. The storage requirements are never changed by a cast. Casting requires an intimate knowledge of the byte order of the system and an awareness of any alignment requirements.
RegulatorRectifier (talk) 17:58, 4 December 2008 (UTC)Reply
In ABAP, conversion and casting are also different, and have the same rules as above, with one more possibility that is the possibility to cast only a part of a value, let's say cast the 8 first bits of a 32 bits value to an ASCII character. Boundaries are always checked at runtime and an exception is triggered if they are exceeded. So casting should better have its own article (as downcasting has one, but upcasting not!) Sandrarossi (talk) 14:16, 9 August 2009 (UTC)Reply
Agreed. It is absurd that type casting redirects here. Type casting means to interpret memory as a different type than what it was declared as. This page is about type conversion. — Preceding unsigned comment added by 81.191.75.74 (talk) 14:14, 14 February 2015 (UTC)Reply
Visual Basic
Latest comment: 10 years ago2 comments2 people in discussion
Does anyone know if this article has to do with the properties of 'variant' types in VB and VBA? A variant variable can be any other type of variable at any point of an algorithm, but I don't have the knowledge to assert that is the same as this article. Khullah (talk) 00:07, 29 November 2011 (UTC)Reply
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.