Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [data-types]

The tag has no usage guidance.

2
votes
2answers
84 views

What is the term for the side on which a variable type is written in a given language?

In the case that a type is specified, it could be on the left (before) or the right (after) of the variable name. For example, C, C# and Java have the type specified before the variable: int num = 5;...
-4
votes
2answers
116 views

How the value of the integer variable is stored in a memory by bytes/bits?

In C program I'm doing below stuff int x = 4; Let us assume integer has 2 bytes in this case. So my question here is the variable x will hold two bytes that mean 16 bits. So here how the value 4 ...
41
votes
5answers
9k views

How do variables in C++ store their type?

If I define a variable of a certain type (which, as far as I know, just allocates data for the content of the variable), how does it keep track of which type of variable it is?
3
votes
3answers
176 views

How to store external numeric IDs - as strings or as integers?

Every now and then we programmers need to communicate with external systems (not under our own control). It's frequent that in such cases we need to keep track of some sort of identifiers that these ...
2
votes
1answer
81 views

Differentiating Between ASCII and Unicode in File Spec

I am developing against a file spec that lists the data type for certain fields as CHAR(<length>) The spec is for a fixed width flat file. In most cases, possible values to populate the fields ...
58
votes
16answers
11k views

How should I store “unknown” and “missing” values in a variable, while still retaining the difference between “unknown” and “missing”?

Consider this an "academic" question. I have been wondering about about avoiding NULLs from time to time and this is an example where I can't come up with a satisfactory solution. Let's assume I ...
0
votes
1answer
94 views

Does primitive obsession apply to columns of tables in database?

For example, in a Student object, in order to avoid primitive obsession, I should change public class Student{ public String name; public int age; } into public class Student{ public ...
1
vote
0answers
113 views

Subclassing numeric types for safety

I'm writing something that handles length units, say, metres and feet. I don't want to accidentally convert between them (trying to avoid something like the Mars Climate Orbiter crash). I'd like to ...
8
votes
2answers
511 views

Only one number type in language design

I am currently learning about compiler construction and language design and I am thinking about what native datatypes I want to support in my language. Now there is a whole lot of languages that make ...
0
votes
1answer
48 views

Not sure how to setup my data for a waypoint system

I have a system i've written on paper and am trying to write this into C# in a easy to use manner. I want a series of connected waypoints (where by waypoints can be connected to any number of other ...
3
votes
5answers
371 views

Is there a practical benefit to using the smallest datatype possible?

In C# (and other languages), we can define a numerical variable as a short, an int, or a long (among other types), mostly depending on how big we expect the numbers to get. Many mathematical ...
1
vote
0answers
24 views

React JS: Mixing data types for one state property

In the spirit of minimising state I always have a desire to mix data types for a given state property. For instance, if I were creating a React page that rendered a list of items that could either be ...
1
vote
1answer
532 views

When writing a Qt application is good practice to ALWAYS prefer Qt function implementations, data types, and classes when they are available?

I'm just starting out with Qt and I really want to try and keep my application as separated from Qt as possible in case I decide to use a different toolset later, but at the same time don't want to ...
3
votes
1answer
244 views

Built-in type AND value checking of parameters?

Does any programming language have a concept of checking the type and value of a given parameter without adding an explicit if (myParam < 0) { .. } within the function? A pseudocode example: ...
3
votes
2answers
218 views

Which layer for custom type (DDD)

If I have a custom type (or maybe an enum) like for ex. a Range: Public Class Range Sub New(minimum As Single, maximum As Single) Me.Minimum = minimum Me.Maximum = maximum ...
1
vote
5answers
3k views

Why are Python sets and dictionaries not ordered by default?

I understand the difference between ordered and unordered sets, and I understand why for many purposes, we don't need ordered sets. But all set operations are still possible on ordered sets, and sets ...
1
vote
3answers
951 views

Which is a more efficient way of storing data in a database using Objects or strings (Database design)

Which method is better to store the data in a database and why? Here is a restaurant example. I'm using a SQL database and JSON to communicate with the database. Imagine each row is a column in a ...
0
votes
1answer
296 views

Are C++ types classes? [closed]

I am trying to understand if C++ types are classes, like in Python for example. Otherwise what datatype is the type itself? E.g. int a = 10 what is int? Is just a token label used by the compiler to ...
13
votes
4answers
619 views

About my database date datatype crusade: Valid? Worthwhile? Does anyone else feel it?

I spend a lot of time answering SQL questions over on SO. I frequently come across queries of this ilk: SELECT * FROM person WHERE birthdate BETWEEN '01/01/2017' AND '01/03/2017' SELECT * FROM ...
-2
votes
2answers
398 views

Why do data types like int and float have maximum values

in C#, an int data type has a maximum value of 2,147,483,647 and a float maximum value is 340282300000000000000000000000000000000 what causes these data types to have maximum values, where do those ...
11
votes
1answer
350 views

What are some intuitions that support calling the Maybe constructor in Haskell “Just”?

The intuition of an optional type like Maybe Int is that either there is no Int (thus, there's Nothing there) or that there is some Int; there is something there. It makes sense to me that we call ...
2
votes
1answer
742 views

Best Practice for Potentially Large JSON Numeric Vaues

I raised this issue on the github project for RazorJam.Insightly, where as you can see it turns out that an error is occurring because for the particular items that I am retrieving and deserialising ...
44
votes
9answers
3k views

What do relational databases gain by setting a predefined data type for each column?

I'm working with an SQL database right now, and this has always made me curious, but Google searches don't turn much up: Why the strict data types? I understand why you'd have a few different data ...
0
votes
1answer
206 views

When were unsigned types first introduced in programming languages?

Recently I learned that standard Fortran does not support unsigned integers. Fortran is a language with a very long history. I suppose that when Fortran was first designed, there simply wasn't any ...
16
votes
8answers
35k views

Use empty string, null or remove empty property in API request/response

When transferring object through an API, as in schemaless JSON format, what is the ideal way to return non-existent string property? I know that there are different ways of doing this as in examples ...
3
votes
2answers
313 views

How to test abstract data types that I implement myself?

How does one even approach testing an abstract data type? I mean, besides the normal (supposed) way of doing unit tests, where you mock the collaborators, feed them in the class to test, together ...
7
votes
4answers
360 views

Subtyping without adding state or behavior - Bad Practice?

Observation There are many Exception subtypes that don't have any added state or behavior. For example, ClosedByInterruptException code. Question Why is subtyping without adding state or behavior "...
0
votes
1answer
71 views

Where to format number strings? Server or browser?

I am storing numbers in my database without formatting (e.g., 1434587). But I need a formatted string in the UX (e.g., $1,434,587). Is it better to store the raw number AND the formatted value in the ...
3
votes
2answers
602 views

Is a linked list considered a collection of objects?

Sedgewick's Algorithm 4ed says Several fundamental data types involve collections of objects. Specifically, the set of values is a collection of objects, and the operations revolve around ...
2
votes
3answers
319 views

Primitive types vs fundamental types?

I have heard both "fundamental types" and "primitive types" being used. Is there a difference in what the two phrases are referring to?
1
vote
2answers
274 views

What is the proper way to implement an abstract data type in C?

In his book Patterns in C, Adam Petersen describes using a pointer to a struct, which is declared in a header file, to create a first-class abstract data-type: /* Customer.h */ /* A pointer to an ...
4
votes
2answers
1k views

Can an interpreted statically typed language be considered type safe?

First let me explain what is my understanding of the terms statically typed language and type safety: Statically typed language: a language that does not allow you to change the type of a variable at ...
18
votes
7answers
1k views

Why does Java have primitives for different size numbers?

In Java there are primitive types for byte, short, int and long and the same thing for float and double. Why is it necessary to have a person set how many bytes should be used for a primitive value? ...
20
votes
3answers
2k views

What should be the datatype of the tokens a lexer returns to its parser?

As said in the title, which data type should a lexer return/give the parser? When reading the lexical analysis article that Wikipedia has, it stated that: In computer science, lexical analysis is ...
0
votes
6answers
313 views

Dealing with a variable that is a number, but has greater meaning? [closed]

I've been working on some embedded code that handles a Bluetooth Low Energy (BLE) radio. BLE has 40 channels, numbered 0 through 39. One function for the radio driver takes in the channel and sets ...
0
votes
1answer
108 views

How should I handle Stored Procedure parameters that need to be the same length as a column?

I'm writing a lot of stored procedures for a SQL Server database that take an id or code that is a CHAR instead of an INT. Most of these haven't changed size in a long time, but when a customer wants ...
-2
votes
1answer
858 views

What is 16 bit word's equivalent in decimal?

Question: For a 16 bit word with 6 bits for an opcode How many different instructions could I fit into the instruction set? What is the largest number that I could use as data? Answer:...
6
votes
2answers
227 views

Casting a nullary data constructor between types

Suppose I have a parametrized data type with more than one nullary (constant) data constructor, such as: data Check a = Valid | Invalid | Unsure a Sometimes I want to manipulate the non-constant ...
3
votes
1answer
181 views

Why do we use architecture-specific types in C

I think that the type names in Rust are much better than the ones in C. I'd choose f64 over double and u32 over unsigned int or uint_32t any day. Is there any reason (other than tradition) to use ...
2
votes
2answers
4k views

API Design: Should I use strings or an enum for dictionary keys

I am working on an API in C#. I am trying to think about the simplest way to expose my API for consumers of it. In particular, I have a class in my exposed data model that has a dictionary property. ...
3
votes
1answer
314 views

Why and when would you use a .NET framework data type?

I've seen an increasing trend of people submitting code to SO that includes the use of .NET Framework data types. I understand that the .NET Framework has its own data types (like Int16, Int32, ...
2
votes
3answers
169 views

Should I only declare the variable as integer if I can perform calculations on it?

Been thinking this for a while now, for example I have a UX that let's the user choose what IP to connect. I have numericUpDown1, numericUpDown2, numericUpDown3, numericUpDown4 to limit the user to ...
105
votes
4answers
11k views

Does a `long` ban make sense?

In today's cross-platform C++ (or C) world we have: Data model | short | int | long | long long | pointers/size_t | Sample operating systems ... LLP64/IL32P64 16 32 32 64 ...
3
votes
2answers
712 views

How does long long syntax work when int int doesn't in C++?

I was wondering if long long specifies a single datatype then why don't things like int int work? I meant obviously that's not a data type but there is a long data type. Essentially what I'm asking ...
3
votes
4answers
1k views

Why isn't there a primitive “complex number” type in Java?

Does anyone know why something like cj library for complex numbers was never completed and integrated into mainline Java? This seems like a no-brainer... I realize the Java gawds don't want to turn ...
2
votes
2answers
97 views

How do I decide whether to make an Input/Output data type an array or a class?

I have some input that I send to a computational library, which processes the input and produces some output. Question: What considerations do I take into account to help me decide whether the ...
0
votes
1answer
75 views

Does variable type specification lead to any performance difference?

Let's say I have a very long method which basically creates a responsive and resizable layout for a user interface by using a few fixed values and a few variable ones taken from an element's ...
1
vote
1answer
240 views

What is the difference between ADTs and objects? [closed]

This question was answered in "Understanding Abstract Data Types (ADTs)", and the top voted answerer (by Frank Shearar) is currently as follows: Objects are not ADTs (*) [editor's note: Links to "...
4
votes
2answers
380 views

How and when did it happen that, a type is an interface?

I came from a highly functional and procedural background in programming, and never knew that a type is the same as an interface. As in the Design Patterns book by GoF, it says: A type is a name ...
0
votes
5answers
204 views

Confusion about data types, compilers, hardware data representation and static vs dynamic typing [closed]

I am trying to understand static vs dynamic typing, but am really struggling to see how everything fits together. It all starts with data types. As far as I understand, data types are quite abstract ...