Questions tagged [type-conversion]

Type conversion is the way of implicitly or explicitly changing an entity of one data type into another. This is done to take advantage of certain features of type hierarchies or type representations.

type-conversion
2,455 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3 votes
0 answers
742 views

Symfony3 convert postgres column timestamp(6) without timezone to valid type

I try to build an application with symfony 3.3.1 using a Postgres 9.2 database. The database schema already exists and can't be changed. In the following example I'm trying to fetch a Stud object ...
Vencarii's user avatar
3 votes
1 answer
1k views

Can I convert a list with objects into a two dimensional array

I don't know if this is possible in c# but it would be great if it was. I have a list of objects which is very easy to convert into an array with the code below: object [] myArray = wrd.ToArray(); ...
cop77's user avatar
  • 79
3 votes
1 answer
2k views

How to avoid casting while extracting fields from GenericRecord in avro?

I am working with Avro and I am trying to extract few fields from it in a generic way. I have a GenericRecord object from avro and I want to extract few fields from it. Below are the methods which ...
user avatar
3 votes
1 answer
1k views

applying sign to dicom image for 16 bit

I am trying to develop a dicom image viewer. I have successfully decoded the image buffer. I store all the image pixel values in an unsigned char buffer in C++. Now, when I display the image it is ...
user6848035's user avatar
3 votes
0 answers
305 views

How do I overload TYPE* conversion from another pointer?

I can't seem to find anything that deals with this type of operation. I have a class TextButton : public TextDecorator class that I want to overload the implicit conversion operator for. The ...
MarcD's user avatar
  • 598
3 votes
0 answers
1k views

No typeTag available Error in scala spark udf

I am getting no typetag found for Seq[String] while compiling the following code val post_event_list_evar_lookup: (String => Seq[String]) = (pel: String) => { pel.split(",").filterNot(_....
ab_'s user avatar
  • 407
3 votes
2 answers
102 views

sqlplus to csv scientific number conversion

I have the following in Unix under my shell script: SET linesize 2000 SET pagesize 50000 SET ECHO OFF SET FEEDBACK OFF SET VERIFY OFF SET MARKUP HTML OFF set numwidth 17 set colsep "," select ...
Amir's user avatar
  • 113
3 votes
0 answers
111 views

How to make G++ report about Int to Bool conversion?

Can i enable some options in g++ compiler (version 4.8.5), so that it throw warning for code: if (1) {} Where implicit conversion (int to bool) happened. As far as i understand, -Wconversion ignored ...
Nikita Sivukhin's user avatar
3 votes
0 answers
9k views

Scala java.lang.String cannot be cast to java.lang.Double error when converting double type dataframe to LabeledPoint in Spark

I have a dataset of 2002 variables. All variables are numeric. I first read in the dataset to Spark 1.5.0 and created a Double Type dataframe following the instruction here . Then I converted the ...
machine_learner's user avatar
3 votes
2 answers
7k views

How to declare TypeScript import * type?

How can I explicitly declare type at import * as ... in TypeScript? I'm having this code: import * as UnauthorizedInterface from './interfaces/InterfaceA' import * as AuthorizedInterface from './...
Jabher's user avatar
  • 318
3 votes
0 answers
1k views

How to convert mathml to an image?

I need to convert mathml to image. I tried mathml-image service, but I unable to upgrade python as it needs python 3.4 . So, I dropped trying that way of conversion. I have knowledge in php, so Is ...
Learning's user avatar
  • 858
3 votes
3 answers
262 views

How to compare Signed Char to a literal constant?

The API provides a function signed char getDirection();, that returns 1 for "forward", 0 for "motionless", -1 for "backward." And of course, as explained in these questions, a simple comparison: ...
SF.'s user avatar
  • 13.9k
3 votes
1 answer
250 views

Tool for transforming variables of different types in Java

Suppose I want to perform some non-trivial(not just though type casting) transformations for a variable v, e.g., from type T1(String) to T2(List): String v = "123"; List<Integer> list = new ...
Yu Feng's user avatar
  • 303
3 votes
1 answer
738 views

How to convert double to char[] by myself in c++?

Since i have to convert lots of double to char[] very fast, after step into sprintf, i found that _cfltcvt_l did the real conversion work, and before _cfltcvt_l is called, it has many switch,case,...
user1024's user avatar
  • 1,022
3 votes
0 answers
3k views

pandas astype str formatting

I have a column in a csv I am reading in with pandas that contains years. Because some of the columns are missing they get NAN and the type of the column is float. I convert the row to string to do ...
lathomas64's user avatar
  • 1,622
3 votes
0 answers
2k views

Java: Read a CMYK image to BufferdImage and keep the right color model

I used the twelvemonkeys collection (extending the imageio functionality (very helpful, thank you for that)) to build an image converter (change format, scale, etc.). Until this converter has to deal ...
joern.iwersen's user avatar
3 votes
0 answers
387 views

Implicit conversion to any templated type

As part of a method to check the existence of specific free functions, I have a type that is designed to be implicitly convertible to any other type: struct AnyConvert { template <class Dest> ...
Azoth's user avatar
  • 1,662
3 votes
1 answer
539 views

fast way of converting tar.gz with single file into .gz

I have bunch of huge .tar.gz archives that contain one file each. Is there easy and light way of converting them to .gz? Something that will strip TAR header from gzipped file without uncompressing it ...
Leszek's user avatar
  • 1,340
3 votes
0 answers
359 views

Type-level Shapeless : aggregating a HList type elements

I want to fold a HList with this Monad but at the type-level trait TypeMonad{ type Append[A,B] = A with B type Identity = Any } Hence, the HList : "A :: B:: C :: HNil " would give the type " A ...
Coo LHibou's user avatar
3 votes
1 answer
974 views

Struts 2 - Saving value in map inside a map

I'm currently working with Struts 2 and I have this situation: In my Action class: private Map<String, Map<Integer, MyEntity>> map; public void setMap(Map<String, Map<Integer, ...
johncol's user avatar
  • 584
3 votes
0 answers
6k views

converting unsigned char * to jbytearray

I am trying to convert an unsigned char * to jbyteArray using the following code int callWR(const char *name,unsigned char *ubuf) { jbyteArray bArray=env->NewByteArray(strlen((const char *)...
user1542790's user avatar
3 votes
1 answer
563 views

performance when converting an integer into its bytes characters representation in python

To be specific I need to convert an integer, say 9999, into bytes, b'9999' in python 2.6 up to python 3.x In python 2.x I do b'%s'%n while in python 3.x ('%s'%n).encode() Performance in python 2....
Luca Sbardella's user avatar
3 votes
1 answer
268 views

C++ Conversion Operator Overloading issue

I have my own SmartPointer class. There are cases where SmartPtr contain a class that inherite from a Base class, and I would like to convert SmartPtr<ClassX> into SmartPtr<BaseClassOfClassX&...
JP.'s user avatar
  • 495
3 votes
3 answers
1k views

Can't convert Dictionary<string, List<string>> to IReadOnlyDictionary<string, IReadOnlyCollection<string>>

Can anyone explain this problem? Dictionary<string, List<string>> x = new Dictionary<string, List<string>>(); IReadOnlyDictionary<string, IReadOnlyCollection<string>...
Yahav's user avatar
  • 211
3 votes
1 answer
3k views

How to show video/mp2t in HTML?

I have this stream, which when i try to download show format video/mp2t and keep downloading because it is stream and i cannot get any file like m3u8 or something like that. Here is link of that ...
Vladimir Mihajlovic's user avatar
3 votes
3 answers
346 views

Parse and TryParse

I wanted to know what others are doing with parse/try parse for decimals as an example. In PHP, I would write a method called GetValueOrDefault(value, default) that takes in two parameters - the first ...
user3520332's user avatar
2 votes
2 answers
127 views

How to handle minus signs with pandas?

I went on a journey with pandas when I was trying to read a .csv file that I would like to share with you in the hopes that someone could enlighten me on some of the points. I will mark my questions ...
Topi Löytäinen's user avatar
2 votes
0 answers
532 views

How to Convert SVG Images to PNG without Loosing Dimensions Using PHP

I tried to convert a SVG image to PNG using meyfa/php-svg PHP Library. Here is the code <?php require __DIR__ . '/vendor/autoload.php'; use SVG\SVG; $image = SVG::fromFile('new.svg'); $doc = $...
Janith Umeda's user avatar
2 votes
1 answer
70 views

How not to write empty cells from excel while converting to xml

I have excel that i am trying to convert into XML. I want to part the data into two parts that both have the start and end. So the XML should look like <Contract> <part> <...
JaniH's user avatar
  • 51
2 votes
0 answers
129 views

How to make rp2040 DynPin usable for Adc with OnesShot read

I am trying to convert from a type erased type to a value type. I have the following struct that accepts DynPin , which is the type erased type of a rp2040 gpio pin. pub struct PhProbe{ ...
elhe's user avatar
  • 132
2 votes
0 answers
113 views

Why does numpy make a type casting for np.float16(3.0) + 0 and np.float32(3.0) + 0?

Can you explain why such type casting is performed? In [49]: type(np.float16(3.0) + 0) Out[49]: numpy.float64 In [50]: type(np.float32(3.0) + 0) Out[50]: numpy.float64 Although the following works ...
zell's user avatar
  • 9,990
2 votes
0 answers
1k views

how to convert class to type in typescript?

I need to use class as generic parameter so need to convert class to type. I have, class SomeClass{ public member1: string; private member2: string; protected member3: string; private method1 ...
user14082's user avatar
  • 411
2 votes
1 answer
2k views

Is there any way to transform a variable (let) to constant (const)?

Does Rust have a method to transform a variable declared as let to a constant? I would like to initialize an array with the size defined by the variable (tam), as I couldn't, I initialized with the ...
Dados Chatos's user avatar
2 votes
0 answers
278 views

Clean way to have a function accept u16 and usize, including unconstrained small positive integer literals

I'd like to have a function accept both u16 and usize, and be able to call it those ways: usu(1 as usize); // 1 usu([1,2].len()); // 2 usu(3u16); // 3 let u16 = 4u16;...
Denys Séguret's user avatar
2 votes
0 answers
246 views

use React-typescript with custom typescript transformers (using ttypescript)

I have a typescript transformer I regularly use in the backend (Nodejs typescript), and I want to use it in the frontend too (React typescript). for that, I need to use ttypescript wrapper so the ...
ar36el's user avatar
  • 1,026
2 votes
0 answers
95 views

Why does PowerShell converts array to ArrayList when nested in Hashtable and returned from a job

Consider snippet below $JobResult = Start-Job -ScriptBlock { $Result = @("foo", "bar") Write-Host "Returning type $($Result.GetType().Name)" $Result } | ...
pavel1269's user avatar
2 votes
0 answers
4k views

Convert image file to webp on upload

Trying to write script which will convert image type (gif, jpeg, jpg,png) to webP in addition to uploading original file for fallback in browsers not supporting webP (earlier versions of Safari, etc.) ...
Monkeework's user avatar
2 votes
1 answer
1k views

seconds since date to date in R

I have a dataset file with a time variable in "seconds since 1981-01-01 00:00:00". What I need is to convert this time into calendar date (YYYY-MM-DD HH:mm:ss). I've seen a lot of different ...
Laia Alcubierre Lorenz's user avatar
2 votes
0 answers
66 views

Why does IEEE 754 categorize convertFromInt and convertToIntegerXXX as arithmetic operations and not conversion operations?

IEEE Std 754-2019: 5.4.1 Arithmetic operations ― formatOf-convertFromInt(int) ― intFormatOf-convertToIntegerXXX(source) Question: why convertFromInt and convertToIntegerXXX are categorized as ...
pmor's user avatar
  • 5,733
2 votes
0 answers
77 views

Number::toString() abstract operation

I'm trying to understand how the Number::toString(x) abstract operation works. From what I can make out, the gist of it seems to be that very large (n > 21) and very small (n < 6) numbers are ...
user51462's user avatar
  • 1,738
2 votes
1 answer
2k views

Converting back from Javascript to Typescript

Is there any way to transpile back the Javascript code to Typescript, which has already been transpile to Javascript, from Typescript using Typescript compiler? (Eg: tsc helloworld.ts) The issue is I ...
Venura Nimesh's user avatar
2 votes
0 answers
80 views

Heisenbug with Julia's parse?

On today's Advent of Code I needed to parse strings into integers. The function I wrote for that was function fd(s::String, fromto::UnitRange)::Bool try parse(UInt, s) in fromto catch ...
primfaktor's user avatar
  • 2,945
2 votes
1 answer
117 views

Im trying to read a txt file into a linked list, that contains both integers and strings in a line, separated by commas

Im making a database, where the information about books and readers in a library are contained in two linked lists, and each line of the txt file contains the data of one book/peopleinlibrary. Data of ...
David69420's user avatar
2 votes
0 answers
89 views

Type system whose implicit conversions form a bounded lattice?

I've been working on an "OOP inspired" type system (for the Zeolite Programming Language) that has a particular feature that I haven't encountered before: The implicit conversions between ...
Kevin P. Barry's user avatar
2 votes
0 answers
434 views

Converting and R object defined inside of a function to a Python object fails using Reticulate in RMarkdown

I want to write an R function in RMarkdown, where I declare an R object inside the function and then convert this object to a Python object that I then pass to a Python function. However, during the ...
Peter's user avatar
  • 191
2 votes
2 answers
768 views

How to convert to int the “val” of the TextInput on the prop “OnChangeText”. React Native

I am learning React Native and I am creating a simple application that performs the solutions of the quadratic formula. The problem is at the moment when I capture the numbers in TextInput using the &...
arturogaag's user avatar
2 votes
3 answers
190 views

python : conversion a dataframe column with commas and $ into float

i'm trying to convert a column of prices in a dataframe into float and then calculate the mean of the first 5 rows. first i did it succussefully in this way : import pandas as pd import numpy as np ...
Ilyes A's user avatar
  • 21
2 votes
0 answers
378 views

Cast sympy boolean expression to sympy integer

Let's say I want to build an integer from some separated boolean values applying some boolean logic In pure python I can do something like this. as_flags = lambda x1, x2, x3, y: x3 + 2 * (x2 | y) + 4 *...
Kosma's user avatar
  • 29
2 votes
0 answers
103 views

Portability of auto kind/type conversions in numerical operations in Fortran

According to the Fortran standard, if the operands of a numeric operation have different data kind/types, then the resulting value has a kind/type determined by the operand with greater decimal ...
Matt P's user avatar
  • 2,317
2 votes
1 answer
1k views

ValueError: buffer is smaller than requested size when trying to read a .dta file

dta files I want to convert to csv from .dta as I don't have Stata which is normally used to open the files. When trying to write the file into a variable on opening it I get the error: ValueError: ...
Gideon's user avatar
  • 21

1
2
3 4 5
50