Questions tagged [type-conversion]

1

votes
1

answer
2.9k

Views

xamarin convert entry text to numeric value

I'm new user of Xamarin studio 5.9.5 (build 9) on Windows, and I want make a form based application that involves some mathematical calculations (.Net + Gtk#). I made a simple form containing 3 Entry widgets (2 for input values and 1 for output value) and 1 button. Here is the code for the button (s...
Issak Sdu
1

votes
1

answer
377

Views

How to convert firebase data (snake_case) to Java object (camelCase)

I want to map my firebase data object to my pojo. However, my firebase object property name is snake case, such as; "user_name". I want to use camelCase on my pojo, such as; "userName" I found beautiful answers like this one, however, I couldn't find any sample about snake_case to camelCase mappi...
Efe Budak
1

votes
1

answer
1.7k

Views

Convert RGBA to RGB in Python

What is the simplest and fastest way to convert an RGBA image in RGB using PIL? I just need to remove the A channel from some images. I can't find a simple method to do this, I don't need to take background into consideration.
Jimbo
0

votes
2

answer
16

Views

Parsing and Convert Data Type inside Array Angular 6

I have an dynamically array that contains string data on each part inside, when i was tried to print it with javascript console.log(res) show like this: [{Activity: "Change Request", Total:"4427" },{ Activity: "Design Escallation", Total:"1067"}] And this my code: this.projectservice.getEventActivit...
tonjel
0

votes
0

answer
7

Views

Julia/Dates : convert a timespan from “days” to “year” or “Float64”

I would like to convert a timespan from "days" to "year" or "Float64" let be at timespan t: t = Date("2000-02-04") - Date("1996-06-04") However each following lines give me an error t/365 Float64(t) parse(Float64,t) convert(Dates.Year, t)
ecjb
0

votes
0

answer
8

Views

turning an array of strings into a 2d array of chars

my code reads input from a file that has a maze written inside, inside the file looks like this. 7 7 GOOOOXO XXOXOOX OXOOOXX XXXOOXO XXXXOXX SOOOOOX XXXXXXX (these are each on a separate line not sure how to show that here) the numbers are the dimensions and G is goal S is start, that doesn't real...
EmmanoelD97
1

votes
1

answer
18

Views

Convert string into float for multiple columns in data frame

I am playing with the data set from FIFA 19 and currently trying to convert string value, wage and release clauses into float values e.g. €110.5M into 110500000. Here is my function which takes text as an argument and returns float value: def text_to_num(text): d = {'K': 3, 'M': 6, 'B': 9} new_tex...
krakowi
-1

votes
0

answer
11

Views

Create formatted array from spark dataframe

I have a spark dataframe with the schema: |-- Dest_ID: long (nullable = false) |-- Src_ID: long (nullable = false) |-- Source: binary (nullable = true) |-- Dest: binary (nullable = true) |-- ip: string (nullable = true) And I am trying to convert it to an array with a format of: val edgeArray = Ar...
Joe S
1

votes
1

answer
1.1k

Views

extract 32bit from 64bit integer

I have an uint64_t integral number and extracted the last 32bit into a uint32_t number by the following code: uint32_t getLast(uint64_t v){ uint64_t t= v >> 32; return reinterpret_cast( t ); // type-punned pointer warning } int main() { uint64_t a = 1l
Gabriel
1

votes
3

answer
50

Views

Is conversion between exactly-sized integers always completely defined by the standard?

Consider the following code: #include #include #include int main() { auto x=std::uint32_t(1)
Ruslan
1

votes
3

answer
1.3k

Views

Converting Time to decimal

All i have to do that just find the overtime of employee. The attendance sheet comes in CSV file and I've already saved the data to a table. The data Field hours is 12:10:00.0000000, and The Working Hour per day is 11:00:00.0000000. I've calculated the difference between these two times using Time...
Saranya Rajendran
4

votes
5

answer
80

Views

Java implicit conversion between int and char [duplicate]

This question already has an answer here: Calculating with the char variable in java 2 answers I'm looking for an explanation for Java's behavior when handling the following scenarios. I understand that the ASCII table is arranged so that the value of the character 5 is five positions greater than...
Lachlan Lindsay
1

votes
1

answer
779

Views

SQL Server - convert a column of comma-separated string to JSON array into a new column

I have a SQL Server database with a column called Categories containing comma-separated values in the format nvarchar(50). The length of each column is variable from record to record. I've created a new empty column called CategoriesJSONArray. For all existing records, I need to convert the values i...
Stpete111
1

votes
1

answer
2.2k

Views

How to calculate the range of data type float in c++?

As we can see int has 4 byte in memory, that are 32bits, after applying range formula , we can see range of int -2147483648 to 2147483647. I have calculated the ranges of all datatypes besides float and double and long double. I dont know how they calculated the range of float mentioned below.
1

votes
1

answer
138

Views

Converting midnight in to a date time format in R

I have a very specific problem. I have been trying to convert a date time character into a date time format in R. Example: "2017-05-21 00:00:00". Whenever I try to convert it using strptime and as.POSIXct to a date time format it gives me "2017-05-21". Thanks for any help
Fiona
1

votes
2

answer
84

Views

What's meaning of (size_t)(uint32_t)-(int32_t)(nTableMask)

PHP is written by C,when i read the source code ,I found a stranger Macro expansion,which like below. (size_t)(uint32_t)-(int32_t)(nTableMask) // nTableMask=-8 I use gdb to print (size_t)(uint32_t),it is wrong (gdb) p (size_t)(uint32_t) A syntax error in expression, near `'. but when i change the e...
1

votes
4

answer
71

Views

Convertion from char to int : why (int)givenString.charAt(2) give 48 with givenString = “11001”?

Here was my problem : I wanted to convert a char into an int from a string using the following code : String s = "11001"; int charAt2 = (int)s.charAt(2); //Why this gives 48 ??? System.out.println("charAt2 = "+charAtI); I get on the terminal: 48. Why? That's what I would like to understand. I have a...
Onyr
1

votes
1

answer
63

Views

Converting float value to string without decimal separator

I have float values from 00.00 to 99.99 range. I am trying to convert the float value to a string along with the conversion should remove decimal separator. flaot a = 00.17; float b = 08.56; To remove decimal separator I am multiplying with *100 and converting to string using ftoa() function. a = a*...
verendra
1

votes
3

answer
25

Views

Sublist, converting multi digit string to list of single integers

I am trying to convert a multi digit string in sublists, into sublists of single digit integers. I would like to achieve this using simple list comprehension. Original list: # [[], ['0000000'], ['2200220'], ['2222220'], ['2200220'], ['2000020'], []] Goal List: # [[0, 0, 0, 0, 0, 0, 0], [2, 2, 0, 0,...
Cory
1

votes
2

answer
85

Views

How to convert nvarchar(254) to decimal(7,2)

I have a table with 10M+ rows and want to change the data type of one the columns from nvarchar(254) to decimal(7,2). What is the most efficient and effective query to make this change? I have tried using ALTER in order to make this change, but get an error in SSMS Error converting data type nvarch...
dallen93
3

votes
2

answer
45

Views

How can I declare an uint8_t array in Java

I have a C++ Function in my DLL that needs an uint8_t array as an input Parameter, so the array looks something like that: uint8_t input[input_length] = { 0x30, 0x41, 0x80, 0x8A...}; I want to use this function in Java with JNA, which means I have to creat an uint8_t array in Java. My first approac...
conryyy
12

votes
2

answer
430

Views

explicit specifier doesn't seem to work when converting an object to bool

I am learning C++ recently and I noticed an example on cppreference, part of which goes like this: struct B { explicit B(int) { } explicit operator bool() const { return true; } }; int main() { B b2(2); // OK: direct-initialization selects B::B(int) if (b2) ; // OK: B::operator bool() } T...
Jinlong Chen
1

votes
5

answer
871

Views

Convert chars corresponding to digits to uint

I need to travers the string ,which should be the string of digits and make some arithmetic operations on these digits for (int i = data.Length - 1; i >= 0; --i) { uint curDigit; //Convert to uint the current rightmost digit, if convert fails return false (the valid data should be numeric) try { cu...
Yakov
1

votes
1

answer
103

Views

Invalid conversion from Foo** to void** - why is implicit type conversion allowed to void* but not to void**?

struct Foo {}; ... void * p = (Foo*)0; // OK void ** pp = (Foo**)0; // Invalid conversion As far as I recall, a pointer to any non-pointer type can be implicitly cast to void* in C++. Why then is the same not allowed for casting a ponter to pointer type to void**?
Violet Giraffe
1

votes
2

answer
3k

Views

415 Unsupported Media Type when I send json to spring controller

I send POST http request with "Content-Type" "application/json" to my controller I have the following dependencies: org.codehaus.jackson jackson-mapper-asl org.codehaus.jackson jackson-core-asl the following controler method: @RequestMapping(value = "sendData.json", method = RequestMethod.POST, cons...
gstackoverflow
1

votes
1

answer
86

Views

Proper way to avoid Implicit Conversion warning when setting an NSCell to a NSUinteger value?

I am converting some old Cocoa code to the current Cocoa system. I have a window that has some cells on it. They are NSCell subclasses. I want to set the value of a cell to the length of an NSRange structure. So my code looks like this: [numPagesCell setIntValue:range.length]; The problem I am getti...
vy32
1

votes
3

answer
99

Views

Javascript checking for float

I've got an app that users input coordinates into. In the DB and most mapping software they use the decimal notation for lat/lng (eg. 123.1234) rather than the older format: 34N 40' 50.12" I need to test that a value input into a form is a float, and not a string. But using parseFloat on 34N 40' 5...
julio
1

votes
1

answer
250

Views

Why a simple bimap ( std::string <-> int) does not work?

A puzzling question to C++ template and type conversion is shown below... To make my life easier, I defined a template class to model a one-to-one relationship using a class BiMap: #include #include #include #include template class BiMap { public: T2& operator[] (T1& t1) { return d1[t1]; } T1...
zhanxw
1

votes
2

answer
148

Views

Generics and objects conversion in C#

I have a class which is handling objects same way. It's like: class Handler{ private T _obj; public T obj{ get{ ...//do sth return _obj; } set{ ...//do sth _obj = value; } } ... // some other properties, no T anymore } There are large amount of code working on Handler objects, ignoring type. I mean,...
Ari
1

votes
1

answer
270

Views

what happens in ASP Classic when you multiply a value that cannot be parsed as an integer by an integer?

suppose you have something like: Dim x, y x = Request("x") y = x * 2 If x cannot be parsed as an integer, will there be an exception or will the resulting expression be parsed as an int?
John Smith
1

votes
2

answer
760

Views

Why does SQL Server conversion to bigint cause an error?

I am trying to convert varchar to bigint: select convert(bigint, (select(Replace((select value from sometable), ' ', '')))) Why is it giving error??? Error converting data type varchar to bigint. thanks in advance Update This is part of query I am trying: select top 1 * into #tblTemp from testTabl...
nan
1

votes
2

answer
409

Views

Unexpected conversion of $_GET[“var”] to integer

I have the following snippet in a page running under PHP 5.4.10 (notice the === in comparison). $list_all_pages = False; $reqs_per_page = 50; $start_page = 0; if (isset($_GET["p"])) { echo("Debug: " . $_GET["p"] . "\n"); if ($_GET["p"] === "all") { $list_all_pages = True; } else { $start_page = intv...
Astolfo
1

votes
2

answer
800

Views

Can I walk through a multidimensional array in PHP and convert the type from strings to integers if they contain only numbers?

I have a multidimensional array that has some values that are strings, and some values that are numbers. When I convert the array into a JSON object, I get a result that looks like this: "A" : "1", "B" : "Text", "C" : "3" The goal is to have a JSON that looks like this "A" : 1, "B" : "Text", "C" : 3...
Questioner
1

votes
1

answer
354

Views

MYSQL turning INT field to BIGINT, without loss of data

I currently have a mysql table which is reaching the maxint mark with the autoincrement column. Is it save to change the field type to Bigint without loss of data? Or do I need to use a duplicate table with a bigint field, copy all data, and then remove the original and rename the copy to be sure I...
Tschallacka
1

votes
5

answer
816

Views

Android - parse String longitude to float causes error

I need to convert my CMS data (which are provided as Strings) to float value, but I am getting exception NumberFormatException: invalid float value: "16.385837" The code looks like: Double.valueOf(myString.trim()).doubleValue(); I've also tried like this: Double.parseDouble(myString).doubleValue();...
botang
1

votes
2

answer
277

Views

Conversion of constrained generic params from subtype to supertype

I have a generic function like this: private LOCAL_TYPE RemoteToLocal(RemoteObjectBaseType remoteObject) where LOCAL_TYPE: EntityBase { Type t = typeof(LOCAL_TYPE); if (t == typeof(FavoritePlace)) { return new FavoritePlace(remoteObject as RemotePlaceType1); } } Where EntityBase is non-abstract clas...
Haspemulator
1

votes
1

answer
3.5k

Views

Converting int/long zero to double

Considering this code snippet: int i = 0; double d1 = (double) i; long l = 0L; double d2 = (double) l; Running this on my machine prints 0.0 for both conversions. But can d1 and d2 ever be anything but 0.0? As I understand, this is a widening primitive conversion to which the spec says: A widening p...
mindas
1

votes
1

answer
1.2k

Views

Converting strings to enumerated types in C#?

I want to persist the currently selected value of a combo box and restore it at a later time. To manage the value in the combo box I have an enumerated type with description attributes. The description attribute becomes (one of) the combo box string values at runtime and the enumerated constant as...
Robert Oschler
1

votes
2

answer
95

Views

equivalent data structure of LinkedHaspMap in guava or apache commons lang

I have a LinkedHashMap based on "Double" data types. LinkedHashMap meetingRecord; I want it to be in primitive data type LinkedHashMap meetingRecord; As far as I know from different search, Java by default has no such data structure available and I need to use something from guava-libraries or comm...
Osman Khalid
1

votes
2

answer
337

Views

C++ Cascading type conversion

How do I get type conversion to work when cascading the type conversions? The following code should be simple, but converison from TypeB to int requires the compiler to deduce two type conversions automatically. But it does not. I can not simply implement operator int() const { return val; } on the...
user2099460

View additional questions