casting Questions

4

Solved

Is there a succinct operation in JavaScript (ES2015) that does this: x => x === undefined ? 0 : x I keep running into situations where I want to increment x, but it's initially undefined, so ...
Anelace asked 4/1, 2017 at 2:57

6

Solved

I have a char array that is really used as a byte array and not for storing text. In the array, there are two specific bytes that represent a numeric value that I need to store into an unsigned int...
Sarcocarp asked 25/10, 2011 at 17:12

7

Solved

I have base class as Animal and child class as Dog Here is the code: class Animal { public int Legs { get; set; } public string Name { get; set; } } class Dog : Animal { public int noOfTail ...
Airtight asked 3/2, 2018 at 10:40

10

Today, I noticed that when I cast a double that is greater than the maximum possible integer to an integer, I get -2147483648. Similarly, when I cast a double that is less than the minimum possible...
Trihedron asked 8/2, 2009 at 17:27

2

Solved

This is a very specific problem and I haven't heard back from the author, so I thought I would throw this out and see if my sanity is intact or not. This is in regard to this video regarding DMA on...
Vicissitude asked 1/7 at 2:32

3

This is a question that I wondered about since the lambdas had been introduced in Java, and inspired by a related question, I thought that I might bring it up here, to see whether there are any ide...
Napiform asked 31/3, 2016 at 14:51

3

Solved

I am trying to cast a smallint to a boolean in PostgreSQL. This does not work out of the box, for example: select (1::smallint)::bool; returns "ERROR: 42846: cannot cast type smallint to boolean...
Lakenyalaker asked 10/7, 2015 at 14:48

7

Solved

I'm trying to cast a CHARACTER VARYING column to a DATE but I need a date format like this : DD/MM/YYYY. I use the following SQL query : ALTER TABLE test ALTER COLUMN date TYPE DATE using to_date...
Hocker asked 19/6, 2014 at 8:23

8

Solved

I have an object of class Foo: class Foo extends Bar { protected $a; protected $b; } $obj = new Foo(); What I want (and have) to do is cast this object to an array, like this: $arr = (array)...
Airbrush asked 20/6, 2012 at 14:16

3

Solved

I use jq to transform a complex json object into a tinier one. My query is: jq 'to_entries[]| {companyId: (.key), companyTitle: (.value.title), companyCode: (.value.booking_service_code)}' compani...
Anticlockwise asked 20/2, 2018 at 14:38

13

Ive some classes that share some attributes, and i would like to do something like: $dog = (Dog) $cat; is it possible or is there any generic work around? Its not a superclass, or a interface o...
Badillo asked 9/2, 2010 at 1:16

13

Solved

I am asking a quite simple question, but I am bit confused in this. Suppose I have a class Parent: public class Parent { int name; } And have another class Child: public class Child extends Pare...
Battista asked 28/8, 2012 at 12:49

7

Solved

This is likely a a novice question, but google surprisingly did not provide an answer. I have this rather artificial method T HowToCast<T>(T t) { if (typeof(T) == typeof(string)) { T new...
Zootoxin asked 3/11, 2010 at 22:55

9

Solved

I have a void pointer returned by dlsym(), I want to call the function pointed by the void pointer. So I do a type conversion by casting: void *gptr = dlsym(some symbol..) ; typedef void (*fptr)()...
Saccharate asked 8/7, 2009 at 6:7

12

Solved

If I have: void MyMethod(Object obj) { ... } How can I cast obj to what its actual type is?
Clein asked 2/9, 2012 at 7:18

12

Solved

I want MyInterface.dic to be like a dictionary name: value, and I define it as follows: interface MyInterface { dic: { [name: string]: number } } Now I create a function which waits for my type: ...
Leeke asked 3/5, 2016 at 13:45

26

Solved

I want to determine if a value is integer (like TryParse in .NET). Unfortunatelly ISNUMERIC does not fit me because I want to parse only integers and not every kind of number. Is there such thing a...
Harappa asked 9/5, 2012 at 14:6

2

Solved

When I'm executing the following code in PHP (v5.5.9) something unexpected happens: $valueAsCents = 54780 / 100 * 100; var_dump($valueAsCents); var_dump((int) $valueAsCents); This returns floa...
Mulholland asked 15/9, 2015 at 15:13

36

Solved

I want to convert these types of values, '3', '2.34', '0.234343', etc. to a number. In JavaScript we can use Number(), but is there any similar method available in PHP? Input Output '2' 2 '2.34' 2...
Lickerish asked 16/12, 2011 at 4:8

3

Solved

Is it possible to check (in C++), if types are castable (implicitly or explicitly)? Is there something in the std or is it possible write a function like in C# (C# same Question)? I want to perfor...
Palace asked 20/5, 2014 at 14:13

4

Solved

I am new to generics. Having a Map like private static Map<String, Object> map; and a method like public <T> T getObject(final Class<T> myClass) { return (T)map.get(myClass...
Pebrook asked 13/6, 2012 at 10:30

2

import typing type(typing.cast(int, '11')) still returns <class 'str'> instead of int. Then, what does typing.cast do here?
Intercommunicate asked 21/7, 2018 at 15:34

17

Solved

I created a DataFrame from a list of lists: table = [ ['a', '1.2', '4.2' ], ['b', '70', '0.03'], ['x', '5', '0' ], ] df = pd.DataFrame(table) How do I convert the columns to specific types? In...
Regalado asked 8/4, 2013 at 23:53

6

Solved

Can someone explain me why this: var_dump((bool) 1==2); returns bool(true) but var_dump(1==2); returns bool(false) Of course the second return is correct, but why in the first occasion...
Noiseless asked 5/12, 2011 at 2:39

4

I want to check that a given double/float variable has the actual bit pattern 0x0. Don't ask why, it's used in a function in Qt (qIsNull()) that I'd like to be constexpr. The original code used a ...
Esqueda asked 17/2, 2012 at 12:31

© 2022 - 2024 — McMap. All rights reserved.