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...
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...
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)...
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...
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...
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...
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
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...
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...
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...
2
import typing
type(typing.cast(int, '11'))
still returns <class 'str'> instead of int. Then, what does typing.cast do here?
17
Solved
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...
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
1 Next >
© 2022 - 2024 — McMap. All rights reserved.