Most voted "type-conversion" questions
Type Conversion is the method used to adapt one type of data to another so that it is possible to relate to a target type.
Learn more…239 questions
Sort by count of
-
49
votes2
answers1582
viewsHow can -1 be greater than 4?
How this code can execute in this way? #include <stdio.h> int main(void) { printf("tamanho de um inteiro: %d\n", sizeof(int)); if(sizeof(int) > -1) { printf("4 é maior que -1"); } else {…
-
19
votes2
answers8059
viewsWhat is upcasting and downcasting in the Java language?
What would be downcasting and upcasting in Java? Examples please.
-
18
votes2
answers10850
viewsWhat is the main difference between int. Parse() and Convert.Toint32()?
In C#, there are two ways (among others) to convert other types to int: Convert.ToInt32(valor) and Int32.Parse(valor). What is the main difference between these two forms of conversion?…
-
16
votes2
answers1211
viewsWhat is the difference between using (int)variable or Convert.Toint32(variable)?
What is the difference between them? At what times is it more appropriate to use one or the other? Examples: string palavra = "10"; var numero = Convert.ToInt32(palavra); // ou (int)palavra ? string…
-
15
votes3
answers8488
viewsWhat happens in a conversion from a char to an int?
How it works when you take a variable and do char-48 To transform in integer, as for example in this code I made, I used a date for example "22/05/1994" stored in a char vector and transformed in…
-
13
votes2
answers1019
viewsConvert.Tostring() and . Tostring()
Is there any glaring difference between them? Whether in performance or ways of dealing, what are their particularities? What would be the correct way to use (if there is any difference)?
-
12
votes3
answers1869
viewsWhy (1 == true) is "true" and (2 == true) is "false"?
I was explaining to a friend of mine the difference between == and === in PHP and wanted to demonstrate this through the javascript console. I was going to demonstrate to him that in PHP, the…
-
11
votes6
answers11946
viewsConverting a string to int?
How best to convert a variable string for another variable of the type int?, namely, a nullable of int? Performance is very important in this case because I will be converting several values within…
-
11
votes4
answers455
viewsWhat is the difference between parseint() and operator + before a string?
I saw a colleague convert a string to integer using the syntax var a = +"10" but I always used the parseInt() and the line is usually like this var a = parseInt("10"). Why when placing the operator…
javascript string performance operators type-conversionasked 6 years, 4 months ago Hiago Souza 5,837 -
10
votes6
answers65891
viewsHow to convert a string variable to int?
As I correctly declare a value whole, for he is returning that my variables are strings. n1 = input("informe um número ") n2 = input("informe um número ") soma = n1 + n2 print ("O resultado da soma…
-
10
votes1
answer3523
viewsConvert int or string to Enum
How to convert type variables int and string for a enum?
-
9
votes7
answers7922
viewsConvert an array of floats to integer
Suppose the following: import numpy as np a = np.array ( [1.1, 2.2, 3.3] ) How to convert this array to int without having to iterate each element or using another array? Why do: b = int(a) Gives an…
-
9
votes4
answers459
viewsWhat happens when I convert int to char?
A whole has 4 bytes, whereas a char has only 1 byte. When I make that definition: int a = 1000; // 1111101000 char b = (char) a; I believe it will take only 1 byte of data, but what I want to know…
-
9
votes1
answer8805
viewsSeparate string by number of characters
I’m developing a component to read the file sent by Dataprev with the list of monthly obituaries. This file is a TXT and every 210 characters is a different person. The documentation can be seen in…
-
9
votes6
answers49720
viewsConvert DATA dd/mm/yyyy hh:mm:ss to yyyy/mm/dd
I have a date in the following format 14/12/2015 00:00:00 and need to convert to 2015-12-14 as I can do it on SQL?
-
9
votes4
answers48238
viewsHow to convert a String to Int in Javascript?
HTML5: <!DOCTYPE html> <html> <head> <title>JSTest</title> <meta charset="UTF-8"> <script src="JSource.js"></script> </head> <body>…
-
8
votes1
answer5127
viewsConvert String to Float with Java comma
How do I convert in an elegant way String for float java? The strings are with the Brazilian localization, that is, the values come with comma as decimal separator ("12.345"). I find it so... "ugly"…
-
8
votes1
answer140
viewsFunction to void pointer conversion*
Recently, I was trying to solve a problem in a program of mine in C and, by chance, I came across some answers from Stack Overflow in English which stated that converting a pointer to a function to…
-
7
votes1
answer2547
viewsWhen to use void* and auto*?
C++11 provided us with the type auto (Automatic). It can transfer type for the first time. But before it, people used to use the void*, where you referenced on the pointer. I still use void*…
-
7
votes2
answers1287
viewsConvert Base16 string (Hexadecimal) to Base10 (Decimal)
I have the following string "615769EF", hexadecimal. How to convert it to base10 and let the result be the string "01633118703" ?
-
7
votes1
answer307
viewsConvert Excel (.xls) to (.htm)?
I made a system for a school, where from the Excel file, where are stored all school newsletters, I export to .htm, where it generates some files with this extension and from there I can cut the…
-
7
votes2
answers1882
viewsHow to convert a text to number?
How should I convert a text that I know is an entire number coming externally? It would be something like a ToInt() or something like that.
-
7
votes2
answers347
viewsDoubt about the use of the Join method
I’m doing a Javascript course and I came up with a question in one of the exercises. Below is the exercise: Given the following object array: var usuarios = [ { nome: 'Diego', habilidades:…
-
7
votes3
answers229
viewsHas Javascript changed its rules about what is false or true?
It occurred to me in the part about booleans, the following problem. I have this variable: var name = "10kg" / 10; if (name) { console.log(name); } else { console.log("Not exist"); } The same should…
-
6
votes1
answer237
viewsHow to convert a value in UNIX type Timestamp to Datetime?
How to convert a value to type UNIX timestamp (seconds since 1970), example 1396148400, in a DateTime?
-
6
votes4
answers11111
viewsConverting float to char array in C/C++
I recently took a test and there was a question that asked for a number like 123.456 was shown as 321.456. I thought the best solution would be to convert this to an array of char and then create an…
-
6
votes3
answers905
viewsProblems with Double formatting
I have a method that gets values like string and performs the conversion to other types, my problem is that when converting an information to double It changes its precise value so that it doesn’t…
-
6
votes2
answers830
viewsConversion from date string to datetime C#
I have a method that will receive a string in the "June 15, 2001" format, for example, which is equivalent to the date to be compared, I need to pass this string to a Datetime, as I would do this…
-
6
votes2
answers435
viewsWhat is the rule for converting a binary value to a negative number and vice versa?
I got a gift after the @Maniero answered that question: What is the ~ (til) operator for in PHP? How to obtain the negative value in binary? And how, through torque, to reach a negative value? In…
-
6
votes3
answers10606
viewsConvert object to String?
What is the best way to convert an object to a type variable int? Or there is no such conversion? Example: if (teste == JOptionPane.OK_OPTION) { int linha = tblPessoa.getSelectedRow(); // Aqui o…
-
6
votes2
answers348
viewsRoot with Bigdecimal
I’m racking my brain to turn a root into a code. I know it works kind of like this: Math.pow(625, (1.0/4)) = raiz 4ª de 625 = 5 My headache is that my dice are BigDecimals Sting prazoIn =…
-
6
votes1
answer57
viewsWhy can a double var store an int type?
Why a var of the kind double can store a var of the kind int? Using C# int x; double y; x = 5; y = 2*x; Console.WriteLine(x); Console.WriteLine(y); Console.ReadLine();…
-
6
votes1
answer165
viewsHow does the "+" operator work in Javascript?
Recently I had seen on the website of MDN Web Docs that it was possible to convert a String in a Number even in the example below: let n1 = "10"; console.log(typeof n1); //=> string ("10") The…
javascript characteristic-language typing operators type-conversionasked 4 years, 12 months ago felipe 61 -
5
votes4
answers4168
viewsConvert string to Time
I got a column in the database that gets a guy varchar which corresponds the hours on my app ("HH:MM"). I need to convert this string to a type TIME and then concatenate with a type DateTime.…
-
5
votes2
answers592
viewsHow to convert a Std::string to a Qstring?
I’m trying to make a simple dialog box display my name. See the code. Pessoa *p = new Pessoa("Ronald Araújo", "[email protected]", 23); QMessageBox msg;…
-
5
votes1
answer10937
viewsDifference between Ansistring, Widestring, Unicodestring, Shortstring and String and how to convert
During my Delphi learning I see implementations that use AnsiString,WideString, UnicodeString,ShortString and String but I don’t know the difference between them. Another thing that always occurs to…
-
5
votes1
answer1820
viewsHow to convert string to double without rounding error?
Because the following command: Convert.ToDouble("199998,99") Results in: 199998.98999999 Already the command: Convert.ToDouble("199998,98") Results in: 199998.98000000001 ?…
-
5
votes2
answers1642
viewsHow do you convert an Enum guy into a list?
Is there any way to convert a Enum in List? public enum TiposHospedagem { Casa = 1, Hotel = 2, Pousada = 3, CasaCampo = 4 } I’m trying to run the enum and add to the list, but the foreach does not…
-
5
votes5
answers29254
viewsHow to convert date to dd/MM/yyyy format?
After I published my app, I started to receive the dates in the American format like this:9/14/2016 12:00:00 AM How to format to dd/MM/yyyy? I tried to convert.ToDateTime() more does not work.…
-
5
votes2
answers15372
viewsConversion of an nvarchar data type into a datetime data type resulted in a value outside the range
Code line INSERT [dbo].[Shop_Goods] ([TemplateID], [Name], [Remark], [CategoryID], [Description], [Attack], [Defence], [Agility], [Luck], [Level], [Quality], [Pic], [MaxCount], [NeedSex],…
-
5
votes3
answers1743
viewsTransform Number into binary text
How to achieve the representation of a Number (integer) in binary with Javascript? Ex: 47 = 00101111
-
5
votes1
answer199
viewsConvert uint16_t to int
I’m doing a project where a distance detector stores the distance in a variable uint16_t, and I need to turn it into int to make comparisons, but I can find nowhere how to do it. How to do?…
-
5
votes3
answers253
viewsCannot implicitly convert "decimal" type to "int" in C#function code
This code averages the arithmetic or weighted average of the 3 student grades based on your choice of average according to the use of the Equals, code error is exactly this conversion of decimal for…
-
5
votes1
answer60
viewsWhat is the relation of the "+" operator to the "valueOf()" method in Javascript?
I have a question about the operator +. In this answer on the operator, the following was said: The + can also play the role of a binary operator. In that case, operates on two values. In this…
javascript characteristic-language operators type-conversionasked 3 years, 8 months ago Cmte Cardeal 5,299 -
4
votes1
answer87
viewsQvector to Qimage
I have to turn one QVector 2d in a QImage to display the image on a label. The QVector in the case of an array of integers with a value of 0 to 255 representing an image in PGM or PPM, this vector…
-
4
votes1
answer2088
viewsHow to convert int to Qstring?
I started learning Toolkit today QT and in trying to perform a small test I came across a question: How to convert a whole to QString? Is there a function that receives an integer and returns an…
-
4
votes1
answer488
viewsDifferent numbers become equal after conversion with doubleval
I have 2 values 4850.00 and 4850.01 When I set 2 variables manually with these values and compare using if, returns me different (OK). But in an ERP system I develop I receive 2 values via AJAX.…
-
4
votes4
answers5878
viewsConvert String to Decimal
And I’m having trouble properly converting this string in decimal. decimal.Parse(txtValor.Text)=meuVen.Valor; When I put the conversion in front, it shows error after the =. I don’t know how to…
-
4
votes3
answers16117
viewsHow to transform a string composed of numbers into an integer list?
I have a list with a string: a = ["1, 2, 3, 4"] I want to take each number inside that list, turn them into integers, and return the highest and lowest value of that list. I’ve tried this with the…
-
4
votes5
answers98
viewsConversion of object properties to numbers
I would like to know how to make the values of an object become numbers. I read about the Methods valueOf(), and toString(), but I have not yet figured out how to use them for this purpose, my…