20,065 questions
Score of 0
2 answers
83 views
How do I get IDbTransaction from NHibernate's ITransaction?
I am using NHibernate 5.5.0 and need to pass the NHibernate connection and transaction to some existing ADO.NET code that expects IDbTransaction.
I can get the current NHibernate transaction with ...
Score of 2
0 answers
175 views
explanations about -Wuseless-cast behavior
I commonly use type aliases to be able to change a given type within my program and to give them some semantic, but I have an issue that appeared by adding the -Wuseless-cast to gcc:
#include <...
Score of 0
2 answers
135 views
If use == to compare strings (of numbers) in Tcl why can't you get back the string using cast as text in SQL?
I made a mistake of using == to evalaute two strings instead of eq and when I tried to cast a variable that was a string of numbers to text, after such comparison, the result was a string but after ...
Score of 3
1 answer
209 views
Problem trying to cast char to int in C simple program [duplicate]
I'm starting to learn a bit of C as a side project of sorts. Doing some simple exercises to get a grasp of the syntax and all that, I've come to a problem I cannot explain.
I need to make a small ...
Advice
1
vote
7
replies
140
views
Coverage on casting Pointers to other data types
I have been studying C++ for a bit of time now. I am still a novice, but I continue to learn daily and practice and pickup new things.
One thing I haven't been seeing too much information on is ...
Score of 0
1 answer
223 views
C++ Cast base class unique_ptr to derived class unique_ptr [duplicate]
I have a method in a derived class which I want to call via a unique_ptr to the base class.
How do I cast my unique_ptr to the base class to allow me to call the method in the derived class?
In ...
Score of 1
1 answer
160 views
Octave new versions (for example, 11.1.0) can do arithmetic with integers represented in hex
Using older versions of octave (5.2.0), I could easily add two numbers in hex format:
octave: 1> 0x1122334455 + 0x1122
0x112233446677
In newest version at the time (11.1.0), that same command ...
Best practices
0
votes
3
replies
96
views
Best way to convert Java List<Generic> to Generic[] array?
I was converting a list to an array, following the method shown in Convert list to array in Java and Converting 'ArrayList<String> to 'String[]' in Java. Unfortunately, it doesn't seem to work ...
Score of 5
1 answer
242 views
Is this C++11 implementation of type erasure safe or UB?
I came up with a C++11 implementation of a std::any-like thing. It works according to my testing, but I'm concerned that I might be invoking undefined behavior somewhere without realizing it.
I'm ...
Score of 4
3 answers
184 views
What does exempting (unsigned char *) data type from strict aliasing rule achieve?
I was trying to calculate square root of numbers without including math.h. I thought I could cast a double as a long as they both are 64 bits (in the function magnitude()) :
#define NUMBER -2
#include ...
Score of 1
1 answer
148 views
Create a custom cast (that also accepts $null)
(Continuing from: Cast to custom class in PowerShell) I would like to build a custom cast like:
class CheckBox {
[Nullable[Bool]]$NullableBool
CheckBox([Nullable[Bool]]$NullableBool) { $this....
Best practices
0
votes
1
replies
113
views
Shall type-conversion be the responsibility of a function/method?
I got the following Android UI-code:
OutlinedTextField(value = mainVM.srcAmount.doubleValue.toString(),
onValueChange = { // Implicit generated argument 'it' is a String.
mainVM.setAmount(...
Score of 3
4 answers
377 views
How can I take the raw bits of an int32 and create a float32 from them?
I am currently trying to generate a random float number in C.
And apparently that is a hard thing to do as there seems to be no real library for it, only workarounds with rand() from stdlib,
but those ...
Score of 1
4 answers
206 views
Casting in comparator functions for qsort
I'm new to pointers and trying to wrap my head around how casting and dereferencing should function in comparator functions that qsort takes. My understanding is these always have the signature int ...
Advice
1
vote
4
replies
61
views
How to conditionally constrain Union types in Python?
Type Checking Challenge for AmiNode
I have an interesting challenge when parsing *.ami files.
I use the following recursive type, which has arbitrary hierarchical depth:
AmiName = NewType("...