casting Questions

2

Solved

I have a UInt16 variable that I would like to pass to a legacy function that requires an NSNumber. If I try: var castAsNSNumber : NSNumber = myUInt16 I get a compiler error 'UInt16' is not conv...
Compte asked 10/6, 2014 at 6:55

4

Solved

I'm trying to render an image. I wrote a put_pixel function to write a RGBA pixel into an array that represents the image. The image is one dimensional array that holds i8 values(every byte is a ...
Determine asked 2/12, 2018 at 22:40

1

Solved

Is this C++ code valid or undefined behaviour? The idea is to be able to wrap a POD you have no control over into another struct to provide helper functions but still be able to use it as if it was...
Crowning asked 9/11, 2021 at 19:22

2

I get a linter error but don't know how to fix it final FoodScreenArguments args = ModalRoute.of(context).settings.arguments; A value of type Object can't be assigned to a variable of type FoodScr...
Skeens asked 9/2, 2021 at 15:5

11

Solved

I was confronted with a tricky (IMO) question. I needed to compare two MAC addresses, in the most efficient manner. The only thought that crossed my mind in that moment was the trivial solution - ...
Toreutics asked 31/12, 2013 at 14:40

5

Solved

Beyond the regular boring difference between Cast and As if i know that apple is a Fruit so I can use (Fruit)apple - and it throws an exception if it aint as value can be checked against null to...
Bicknell asked 8/4, 2012 at 18:51

8

I have the following situation: public ArrayList<A> getMethods(){ return b.c.test(); } So, my problem is that b.c.test() returns a value with Optional<A> as return type. But I need ...
Thiol asked 28/7, 2015 at 22:44

14

Solved

I keep finding both on here and Google people having troubles going from long to int and not the other way around. Yet I'm sure I'm not the only one that has run into this scenario before going fro...
Zetes asked 19/8, 2009 at 21:1

7

In this answer, zwol made this claim: The correct way to convert two bytes of data from an external source into a 16-bit signed integer is with helper functions like this: #include <stdint....
Hydroxide asked 26/3, 2020 at 9:41

5

Solved

Can I assume (bool)true == (int)1 for any C++ compiler ?
Roselba asked 27/4, 2010 at 20:54

1

I am learning about templates in C++, and came across an example where casting to void is used: template<typename T> auto func (T const& t) -> decltype( (void)(t.size()), T::size_type(...
Nan asked 24/9, 2021 at 11:52

7

I have two time in the format "HH:MM" i want to compare them i have the following code to get the time of now in my format: current_time = new Date(); hour = current_time.getHours(); minute = curr...
Goodly asked 25/9, 2013 at 12:29

19

Solved

Any way to cast java.lang.Double to java.lang.Integer? It throws an exception "java.lang.ClassCastException: java.lang.Double incompatible with java.lang.Integer"
Arrear asked 1/2, 2012 at 19:53

11

Solved

I am extracting a bool value from a (non-generic, heterogeneous) collection. The as operator may only be used with reference types, so it is not possible to do use as to try a safe-cast to bool: ...
Gallonage asked 29/12, 2009 at 14:36

3

Solved

Does SystemVerilog support downcasting (casting a base object to a derived object)? If so, how? The following downcast example does not work: class base; int a = 5; endclass class extend extend...
Sajovich asked 12/12, 2013 at 16:12

6

Solved

I want to write a function that returns every item in a List that is not the first or the last item (a via point). The function gets a generic List<*> as input. A result should only be return...
Volost asked 12/4, 2016 at 9:41

6

Solved

Consider a class; class temp: def __init__(self): pass I make an object of it; obj = temp() Convert it to string; strObj = str(obj) Now, how can i convert strObj to an object of temp cla...
Squishy asked 16/7, 2015 at 6:19

4

Solved

In one of my queries it appears that the AVG function is returning an int. select ..., AVG(e.employee_level)avg_level How do I get it to return floating point values? I tried casting it but all...
Madlin asked 19/6, 2012 at 17:26

6

Solved

I have an array that looks like this: var arr: [Int] = [1,2,3,4,5] In order to print this, I would like to convert this to: var newArr: [String?] = ["1","2","3",&quot...
Lettuce asked 23/6, 2015 at 13:21

6

Solved

I have a form with different selects like : <select [(ngModel)]="selected.isConnected" (ngModelChange)="formChanged()" name="etat" id="etat" class="form-control"> <option value="0">N...
Highball asked 13/9, 2016 at 15:48

2

This thread addressed how to use TypeTag to get runtime type of type parameters when used with Existential type. Another thread addressed how to cast a variable to its runtime type retrieved from T...
Homocyclic asked 1/4, 2015 at 20:43

6

Solved

From a library I'm working with I recieve an array of ushort. I want to convert them in an array of float: The first ushort represents the 16 MSB of the first float and the second ushort is the 16...
Estragon asked 3/2, 2012 at 14:49

3

Solved

I have a TypeScript interfaces: export interface iA { name: string; } export interface iB { size: number; } export interface iX { id: number; data: iA | iB; } Then in one of my Angular compone...
Rajiv asked 20/7, 2020 at 8:43

3

Solved

I recently learned that it is Undefined Behavior to reinterpret a POD as a different POD by reinterpret_casting its address. So I'm just wondering what a potential use-case of reinterpret_cast migh...
Fanciful asked 29/7, 2021 at 12:38

1

I have a matrix class with a transposedView() method that I have been using for years as a "zero overhead" conversion between row and column vectors. template<int M, int N=M, typename ...
Beckwith asked 29/7, 2021 at 1:36

© 2022 - 2024 — McMap. All rights reserved.