The tag has no usage guidance.

learn more… | top users | synonyms

3
votes
3answers
67 views

Handling Value Unit data

We have some data that is strongly bound to each other and we are using it for calculations. Its a value with a unit type and an optional relation. E.g. 1500 meter above sea level. The unit type ...
3
votes
3answers
402 views

Best practices regarding type mapping and extension methods

I want to ask some questions about best practices regarding mapping types and using extension methods in C#. I know this topic has been discussed multiple times over past few years, but I've read a ...
3
votes
2answers
168 views

Haskell: Is it possible to convert a Num to a Float?

I need to be able to convert generic numbers (instances of Num) to a Float. I searched Hoogle for a function with the signature Num n => n -> Float, but I couldn't find any such functions ...
-1
votes
3answers
1k views

Integer conversion with Console.ReadLine() [closed]

To read an integer from user input, you can use: int number = Convert.ToInt32(Console.ReadLine()); But why won't the following work? int number = (int) Console.ReadLine(); What's the difference ...
13
votes
9answers
4k views

Why can't there be any implicit conversions?

As I understand it, implicit conversions can cause errors. But that doesn't make sense -- shouldn't normal conversions also cause errors, then? Why not have len(100) work by the language ...
0
votes
1answer
125 views

Converting from byte[ ] to user defined type

I am working on a network simulator designed in java with the basic function of routing messages through a network. I am trying to take a Message object, encrypt it using an encryption utility that ...
1
vote
0answers
37 views

Manual repetitive conversion between file types

Let's say i have an interest in file conversions, but everything should be made by hand and i have multiple output formats (say: csv and excel). Once i get contacted by a client, i have to link ...
0
votes
2answers
240 views

Interface (contract), Generics (universality), and extension methods (ease of use). Is it a right design?

I'm trying to design a simple conversion framework based on these requirements: All developers should follow a predefined set of rules to convert from the source entity to the target entity Some ...
3
votes
3answers
1k views

C/C++: Which conversion warnings make sense in practice?

C/C++ implicit conversions can cause bugs. Here's one example: int foo, bar; scanf("%d", &foo); scanf("%d", &bar); float foobar = foo / bar; If I input 7 and 2, it's not 3.5 as expected - ...
0
votes
6answers
5k views

Converting an empty string to a number [closed]

If you are designing a function which should conver a string to an integer, how would you convert an empty string? The question is only about this one particular input value (empty string). Between ...
6
votes
3answers
2k views

Is relying on implicit argument conversion considered dangerous?

C++ has a feature (I cannot figure out the proper name of it), that automatically calls matching constructors of parameter types if the argument types are not the expected ones. A very basic example ...
32
votes
3answers
20k views

What is the name of ** in python?

When programming Python I sometimes do a ** to make a conversion. I understand what it does but what data structures am I manipulating? A dict and what is the other? An array? Is there a name for the ...
7
votes
4answers
2k views

The need for Explicit Type Conversion in C#

Consider the following code: DerivedClass drbObj = (DerivedClass)obj; Here obj is of type Object and this is reasonable since Object is the base type of every Class in C#. Here, since the type of ...
3
votes
3answers
1k views

What is the accepted best practice for Java type conversions?

What is the current best practice for all the type conversions necessary in a Java web application? For example, HttpServletRequest.getParameters(...) returns String[], but Hibernate does not allow ...