casting Questions

5

Solved

Is there a clean way of casting a struct into an uint64_t or any other int, given that struct in <= to the sizeof int? The only thing I can think of is only an 'ok' solution - to use unions. How...
Jigaboo asked 10/8, 2012 at 14:31

4

Solved

In Go, why is there no function which directly calculates absolute value for integer datatypes? Currently all integer values have to be typecast to float64 and then passed to math.Abs(), which retu...
Impersonalize asked 25/8, 2019 at 19:5

14

Solved

When I convert a factor to a numeric or integer, I get the underlying level codes, not the values as numbers. f <- factor(sample(runif(5), 20, replace = TRUE)) ## [1] 0.0248644019011408 0.02486...
Moslemism asked 5/8, 2010 at 18:53

2

Solved

I am able to get the IDs of all the controls of a page and also their type, in the page when i print it it shows myPhoneExtTxt Type:System.Web.UI.HtmlControls.HtmlInputText this is generated bas...
Undersized asked 12/7, 2012 at 19:23

3

I've used C pointers for some time now and everything has always worked as expected. However now I've run into the ISO standard that says "If the resulting pointer is not correctly aligned for...
Centesimo asked 25/7, 2023 at 15:33

8

Solved

My app has a lot of different lookup values, these values don't ever change, e.g. US States. Rather than putting them into database tables, I'd like to use enums. But, I do realize doing it this w...
Halfcocked asked 15/7, 2010 at 14:46

31

I have an enum defined this way: export enum GoalProgressMeasurements { Percentage = 1, Numeric_Target = 2, Completed_Tasks = 3, Average_Milestone_Progress = 4, Not_Measured = 5 } However, ...
Shroudlaid asked 29/3, 2017 at 17:53

5

Solved

I generally prefer to code R so that I don't get warnings, but I don't know how to avoid getting a warning when using as.numeric to convert a character vector. For example: x <- as.numeric(c("...
Janie asked 20/2, 2013 at 16:31

3

Solved

I am trying to write a general purpose wrapper for subscriptions, something like: type Subscriber interface{ Subscribe(addr string) chan interface{} } Suppose there is a library I want to use w...
Consequently asked 31/8, 2014 at 15:19

41

Solved

How do I check if a string represents a numeric value in Python? def is_number(s): try: float(s) return True except ValueError: return False The above works, but it seems clunky. If what you...
Grays asked 9/12, 2008 at 20:3

6

Solved

I am unable to convert a boolean to a string value in TypeScript. I have been roaming through documentation and I could not find anything helpful. I have tried to use the toString() method but it d...
Carine asked 8/2, 2013 at 14:37

5

Solved

I have a question regarding using intptr_t vs. long int. I've observed that incrementing memory addresses (e.g. via manual pointer arithmetic) differs by data type. For instance incrementing a char...
Atlantis asked 13/6, 2011 at 3:16

33

Solved

Is it possible to assign a base class object to a derived class reference with an explicit typecast in C#?. I have tried it and it creates a run-time error.
Mikkimiko asked 8/4, 2009 at 11:12

1

Solved

I'm trying to cast the output data of my ImageDataGenerator to integers. This is my generator: train_mask_data_gen = ImageDataGenerator(rotation_range=10, width_shift_range=10, height_shift_rang...
Brandybrandyn asked 7/12, 2019 at 20:46

31

Solved

I have a class called Questions (plural). In this class there is an enum called Question (singular) which looks like this. public enum Question { Role = 2, ProjectFunding = 3, TotalEmployee = 4...
Indistinctive asked 3/6, 2009 at 6:46

6

Solved

I am working with a DB2 database for the first time. I am trying to work with DB2 dates, but the data is stored as a string in the DB2 database. I want to convert this date-string into an actual ...
Rundell asked 31/1, 2011 at 14:39

8

Solved

I am trying to recursively convert a php object to an array. The function I wrote is this: public function object_to_array($obj) { $array = (array) $obj; foreach ($array as $attribute) { if (is...
Misgovern asked 27/3, 2014 at 0:49

3

Solved

I don't know how to type Svelte 3 reactive syntax variables. <script lang="ts"> import type { Player, Team } from "./types"; import { DEFAULT_PLAYER } from "./util...
Petropavlovsk asked 2/6, 2021 at 10:13

2

Solved

I have a pointer to some volatile memory that I am trying to dereference and copy to a unqualified copy of that structure (and vise-versa). The format of the memory is specified by a third party st...
Extranuclear asked 6/6, 2023 at 0:10

4

Solved

In C# I can convert doubles to floats by a cast (float) or by Convert.ToSingle(). double x = 3.141592653589793238463; float a = (float)x; float b = Convert.ToSingle(x); a and b become equal. Ar...
Emperor asked 4/12, 2015 at 14:17

10

Solved

I am trying to convert hex to decimal using PostgreSQL 9.1 with this query: SELECT to_number('DEADBEEF', 'FMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); I get the following error: ERROR: inv...
Typhogenic asked 29/11, 2011 at 18:55

4

Solved

I have json as follows, { "H": "Macellum", "M": "Receive", "A": [ { "CustomerId": "172600", "OrderId": "69931", "OrderStatus": "E0", "Buy": "A" } ] } and complex type public class Ord...
Fourthclass asked 16/8, 2017 at 13:57

2

Solved

I'm using a library which requires a function with a void* pointer as a parameter. I have a 2D string array and I want to pass that array through that parameter and extract it inside the function. ...
Adham asked 2/6, 2023 at 6:16

12

Solved

Until today, I thought that for example: i += j; Was just a shortcut for: i = i + j; But if we try this: int i = 5; long j = 8; Then i = i + j; will not compile but i += j; will compile fi...

3

Solved

This question is about the 'function pointer' version of qsort from K&R (2e), section 5.11 (p118-121). There are a number of places where I don't understand why or how the casts work, and I sus...

© 2022 - 2024 — McMap. All rights reserved.