Questions tagged [data-types]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
151 views

Wondering about ADT abstract data classes in Python

I am trying to learn a little Python by myself and came accross this book Data Structures and Algorithms Using Python Rance D. Necaise 2011 , to get some proper/formal/correct definitions/terminology ...
pippo1980's user avatar
  • 137
0 votes
2 answers
342 views

How to Represent Functional Boolean

.NET Boolean type usually makes if else pair all over the code. Functional Boolean should be more like Either type. Ideally represented as Either<Unit, Unit>. However, my issues with Either type ...
TIKSN's user avatar
  • 109
1 vote
2 answers
202 views

Implementation of variables in JVM / Java

I know that a lot of interpreted higher level languages like to abstract a lot of things and therefore cannot directly be compared with lower level constructs. For example in some languages primitive ...
tweekz's user avatar
  • 227
1 vote
0 answers
58 views

Haskell: Data Modeling an Internal App that Interfaces with a 3rd-Party Library?

I wrote a java call graph generator with tree sitter (the 3rd-party library in question)'s python binding. I am doing a thought experiment on how I might model the same application in Haskell. I am ...
Acy's user avatar
  • 111
2 votes
2 answers
249 views

Types with same name, same concept, but different... runtime uses?

I keep running into this problem when programming, and I wonder if someone has written about it before, or maybe developed some ideas about it. For an example program, lets say I have a graphics ...
Rob N's user avatar
  • 131
1 vote
2 answers
74 views

If I want to add 'period' in the database (one month), and would like to make calculations with the first day of the period. What would I have to do? [closed]

I have a question. I want to add 'period' in the database. A period would always be 1 month. How Would I be able to make calculations with the period? For example I want to calculate the following: A =...
Rquestions's user avatar
0 votes
0 answers
797 views

Best way to check for truthy values in PHP?

In PHP, there are several ways to check whether a value is true, or similar: true === $v, only works for bool true == $v || !!$v, works with int and string, but a non empty array can also be ...
Gabriel Smoljar's user avatar
2 votes
0 answers
103 views

How to define the data model in an event-based infrastructure

After my team went all-out on the microservice paradigm with an emphasis on message passing, I'm having trouble defining and keeping track of all the events in the system. I've read some guides on the ...
Dzeri96's user avatar
  • 129
0 votes
1 answer
137 views

Parsing complex data type names

How do compilers parse complex data types names like function pointers. The type has to be somehow put into the AST or it has to be processed during parsing. What are the pros and cons of different ...
Wojak2121's user avatar
2 votes
0 answers
92 views

Integer type for data structure index

I have implemented an append-only tree data structure as a class in C++20. Internally it uses std::vector<Node<T>> where Node<T> contains an int parent_index and T payload. A node ...
Martin Ueding's user avatar
-1 votes
1 answer
35 views

Time limit or built-in flush of HashTable entries

Is there a standard data type which is a struct or a table or a dictionary which will always delete objects that are older than t minutes? for example if I want to make sessions expire after 60 ...
Niklas Rosencrantz's user avatar
0 votes
1 answer
123 views

What is the purpose of types which may be replaced by others?

In Kotlin or Java we have many different types: integer, byte, double, long, float, string, character, etc. But one can use an integer instead of byte, and a double instead of an integer. Why we need ...
user avatar
2 votes
6 answers
607 views

What is the viability of engineering an integral type with values ranging from -1 to 254? Do types like this even exist?

In software engineering, often developers will utilize three different states of a signed integer, as a trilean: This tends to be quite typical: -1 - Represents something akin to a null pointer, as in ...
Anon's user avatar
  • 3,603
0 votes
1 answer
227 views

Should all structures be ADTs?

Is there any specific category an ADT must be in? I'm struggling to find out how best to represent objects in the program for example: As a record: struct Person { int age }; Or as an ADT: struct ...
Richard Bamford's user avatar
10 votes
6 answers
1k views

Do any programming languages use types as values? Would there be any point?

The standard way that types are handled in programming languages that have such a concept, is that they are: removed entirely at compile time and are just used to determine memory layout, function ...
AIWalker's user avatar
  • 1,307
-4 votes
1 answer
214 views

What is the Difference Between Float and Double Data Types? [duplicate]

Apart from the memory size of both data types, I want to know any other differences and also want to know when we use float and when we use double?
lokeshjoshi's user avatar
2 votes
3 answers
215 views

Is it called "composition" if we are using primitive data types?

The following is an example of "composition": public class Car { Engine engine; // Engine is a class } But is it still called "composition" if we are using primitive data ...
user247763's user avatar
1 vote
0 answers
47 views

Is there a simpler way to monitor changes to a piece of data, and disallow removing the data from monitoring?

I'm working on an algorithm visualizer for sorting algorithms. Give it a (user-submitted) sorting algorithm, hit run, it'll generate a random list of integers and show you what the algorithm looks ...
Tal's user avatar
  • 141
2 votes
2 answers
200 views

Why do some languages decouple operations from data type?

This is a pretty difficult question to frame. But I'll try my best. In some languages, data types are decoupled from the operations they can perform, while in other languages like JavaScript they are ...
scroobius's user avatar
  • 147
1 vote
2 answers
1k views

Is there a difference between abstract data type and interface?

From what I understand, an abstract data type is basically some data and what we are allowed to do with that data (ex. a list with a set of data and an attribute size and the functions get(), set(), ...
qwerty_99's user avatar
  • 163
3 votes
3 answers
910 views

Why am I getting complex errors even with simple C++ code?

I started to play with C++ recently. One of the difficulties I have quite often is when the compiler tells that there is an issue with the types: more often than not, those compiler errors look ...
Arseni Mourzenko's user avatar
5 votes
3 answers
548 views

How to visualize a Stream object (and some other data types)?

I want to make a small programming tutorial which will have a number of images visualizing various data types, but I am not sure how to draw these images of the data types. Assume that I have a ...
johnny92's user avatar
  • 251
0 votes
3 answers
222 views

What goes into a computer deciding how many memory locations to assign for specific data types in C?

I have learned file memory management and some very simple CPU assembly for manual memory manipulation. Still, I feel like there is a gap in my knowledge when it comes to modern, complex computers, ...
infinity8-room's user avatar
-1 votes
1 answer
107 views

Is there a name for this pattern of composing a type safe return type from different levels of nested related entities?

I have a problem in my app where I have many entities that can all reference each other in different ways. For example, I have a Job (e.g. build house) that I might assign to a team called "Plumbers" ...
Carson Holzheimer's user avatar
3 votes
1 answer
107 views

A size-type vs index-type conundrum

Suppose I'm writing C or C++ code which deals with... ok, let's make it citizens in a state. In this state, citizens have numeric id's (not strings - numbers); and for reasons of performance, or ...
einpoklum's user avatar
  • 2,508
2 votes
5 answers
1k views

How do B-Trees used in databases sort data based on different fields?

I know majority of databases uses B-Trees, and I can see how using a balanced binary tree will give fast sort times, for ordering by ID or whatever else the primary key is; but how are databases able ...
Kartheyan's user avatar
0 votes
1 answer
194 views

How do Haskell Lists Desugar?

So, I was wondering about how Haskell's lists are implemented. I looked it up, and found this: data [] a = [] | a : [a] So I get that you can write lists like this if you want to: a:b:c:[] -- ...
InfiniteDonuts's user avatar
0 votes
1 answer
240 views

What is the correct way to dynamically declare the type of a variable (in Java)? [closed]

Disclaimer: I previously posted this on Stack Overflow, but it seems that perhaps that was not the correct site for the question. If this is still not the correct site, please let me know. I'm ...
asdf's user avatar
  • 11
13 votes
6 answers
3k views

why aren't the platform specific integer types in C and C++ (short, int, long) deprecated?

TL;DR: Why isn't everybody screaming, "Don't use short, int, and long unless you really need to, and you very likely don't need to!" I understand that, in theory, by using the types short, int, and ...
M Katz's user avatar
  • 249
2 votes
0 answers
170 views

Data Types Based Database

I was wandering if there exists some kind of database that organises data based on some declared type rather than tables or collections. I'll try to explain better with an example. Let's say I have ...
Carlo Moretti's user avatar
1 vote
1 answer
790 views

When is it a good idea to include explicit type declarations in Kotlin?

In Kotlin, specifying the return types of functions and the types of variables is usually optional but can be optionally included. I've encountered a few benefits of including them: It sometimes ...
fluidj's user avatar
  • 147
3 votes
1 answer
4k views

Using Null/None/Nil vs empty data types

This question is more coding style related which is why this question is asked here. I'm new to Python, coming from PHP. I've been looking through Python style guides & code examples, I've ...
Michael M's user avatar
3 votes
3 answers
573 views

Language design : How to type higher order functions parameters?

I'm trying to design a theoretical programming language and I'm facing a problem with high order functions. The language is strong-typed, so the way to define a standard function is like so : ...
ibi0tux's user avatar
  • 241
1 vote
2 answers
679 views

What are the "scalar fields" and "composite fields" in JAVA?

Need to understand the below definition, from the protobuf tutorial: mergeFrom(Message other): (builder only) merges the contents of other into this message, overwriting singular scalar fields, ...
RafiAlhamd's user avatar
0 votes
4 answers
1k views

Can int16_t be easier on the processor then int?

I know that the compiler and architecture of a processor also have a role to play in this. But this is more of a "can it" rather then a "does it" question. I have already tried to research this, but ...
skyline's user avatar
  • 11
2 votes
2 answers
319 views

What to do with data types with lots of connections in a UML class diagram

I have a Pose data type, consisting of x, y, and rotation values. This being a robotics application, the Pose data type is used in about a dozen places throughout the application. Connecting all ...
Omegastick's user avatar
1 vote
0 answers
148 views

Convert between enum and discriminated union

Is there a software pattern (or some recommended guidelines) for how to convert between enum values and discriminated unions? Or more specifically: project a discriminated union onto its enum case? ...
Michael's user avatar
  • 289
1 vote
2 answers
166 views

Not understanding ADT concept from book "Object-oriented software construction 2/e"

I've been learning object-oriented concept from this book, and stuck in a specified concept in the middle of chapter 6. No one could understand my question without brief prologue, so I'm starting with ...
Andy Lin's user avatar
  • 185
1 vote
1 answer
560 views

How float data type stores number greater than 2^23? As Mantissa is only 23 bits

Can someone explain how floating point numbers are stored in C, as for 32-bit float, 1 bit is parity, 23 bits for mantissa and 8 bits for exponent. So for numbers greater than 2^23(still in the float ...
Akshay Iyer's user avatar
3 votes
2 answers
123 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;...
rovyko's user avatar
  • 215
-4 votes
2 answers
1k 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 ...
Abdulvakaf K's user avatar
45 votes
5 answers
18k 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?
Finn McClusky's user avatar
4 votes
3 answers
2k 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 ...
Vilx-'s user avatar
  • 5,320
2 votes
1 answer
362 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 ...
mathewb's user avatar
  • 137
58 votes
16 answers
15k 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 ...
exhuma's user avatar
  • 1,191
0 votes
1 answer
197 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 ...
ocomfd's user avatar
  • 5,712
1 vote
0 answers
123 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 ...
ggambetta's user avatar
  • 1,214
8 votes
2 answers
658 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 ...
Niklas Vest's user avatar
0 votes
1 answer
108 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 ...
WDUK's user avatar
  • 2,082
3 votes
5 answers
446 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 ...
mmathis's user avatar
  • 5,488