Questions tagged [primitive]

A primitive type is a data type provided by a programming language as a basic building block.

The actual range of primitive data types that is available is dependent upon the specific programming language that is being used. For example, in C, strings are a composite but built-in data type, whereas in modern dialects of BASIC and in JavaScript, they are assimilated to a primitive data type that is both basic and built-in.

Classic basic primitive types may include:


  • (character, char)
  • (integer, int, short, long, byte) with a variety of precisions
  • number (float, double, real, double precision)
  • number (fixed) with a variety of precisions and a programmer-selected scale
  • , logical values (true, false)

Reference

977 questions
12
votes
3 answers

Where are Rust's boolean and other primitive types implemented?

I was going through the code behind some of the basic types in Rust, e.g. the pleasantly simple implementation of Option or the weird macro magic behind tuple and I was able to find all of the types that I wanted in libcore. All except for one -…
ljedrz
  • 20,316
  • 4
  • 69
  • 97
12
votes
2 answers

Java overloading: reference to call ambiguous

Consider the following example code: public class TestClass { public void doSth(String str, String l, Object... objects) { System.out.println("A"); } public void doSth(String str, Object... objects) { …
Entrusc
  • 197
  • 2
  • 11
12
votes
2 answers

Defining the defmacro function using only LISP primitives?

McCarthy's Elementary S-functions and predicates were atom, eq, car, cdr, cons He then went on to add to his basic notation, to enable writing what he called S-functions: quote, cond, lambda, label On that basis, we'll call these "the LISP…
hawkeye
  • 34,745
  • 30
  • 150
  • 304
12
votes
5 answers

Custom byte size?

So, you know how the primitive of type char has the size of 1 byte? How would I make a primitive with a custom size? So like instead of an in int with the size of 4 bytes I make one with size of lets say 16. Is there a way to do this? Is there a way…
thyrgle
12
votes
8 answers

In C# are the terms "Primitive" and "Literal" interchangeable?

A discussion earlier today led me to question whether or not my understanding of primtives and literals is correct. My understanding is that a literal type is specifically a type which can have a value assigned using a notation that both human and…
STW
  • 44,917
  • 17
  • 105
  • 161
12
votes
2 answers

Are there any good 3rd party libraries build on top of openCL yet?

I'm thinking in particular of processing primitives, things like FFT, convolution, correlation, matrix mathematics, any kind of machine vision primitives. I haven't been able to find anything along these lines, does anyone know of any good projects…
gct
  • 14,100
  • 15
  • 68
  • 107
12
votes
2 answers

What is the use/purpose of primitive type classes?

I recently learned that there are Class representations for the primitive types in the JVM. For example, int.class, double.class, and even a void.class. What I don't understand is why these are there. They don't seem to serve any functional role. …
asteri
  • 11,402
  • 13
  • 60
  • 84
11
votes
9 answers

Comparing Character, Integer and similar types in Java: Use equals or ==?

I wanted to make sure about something in Java: If I have a Character or an Integer or a Long and those sort of things, should I use equals or is == sufficient? I know that with strings there are no guarantees that there is only one instance of each…
Uri
  • 88,451
  • 51
  • 221
  • 321
11
votes
3 answers

How to subtract an isize from a usize?

I've got a usize that does hit very large values. I also apply a delta to it that I receive in the form of an isize. What's the best way to apply the delta without losing any precision? fn main() { let mut big_indexer: usize = 4295032832; //…
Ripread
  • 330
  • 2
  • 10
11
votes
3 answers

Generator G's requirement to be a primitive root modulo p in the Diffie Hellman algorithm

Having searched, I've found myself confused by the use of P and G in the Diffie Hellman algorithm. There is requirementy that P is prime, and G is a primitive root of P. I understand the security is based on the difficulty of factoring the result…
Daniel
  • 111
  • 1
  • 3
11
votes
2 answers

Intersection 3D meshes python

I just started to work with 3D meshes, oriented to be used for finite element analysis. I would like to model inclusions for materials (any shape, but mainly interested in spheres and ellipsoids) in a cube-like matrix. These inclusions shouldn't be…
Ger
  • 349
  • 2
  • 16
11
votes
15 answers

Anyone using short and byte primitive types, in real apps?

I have been programming in Java since 2004, mostly enterprise and web applications. But I have never used short or byte, other than a toy program just to know how these types work. Even in a for loop of 100 times, we usually go with int. And I don't…
Adeel Ansari
  • 39,541
  • 12
  • 93
  • 133
11
votes
7 answers

int vs float arithmetic efficiency in Java

I'm writing an application that uses Dijkstra algorithm to find minimal paths in the graph. The weights of the nodes and edges in the graph are float numbers, so the algorithm doing many arithmetics on float numbers. Could I gain a running time…
jutky
  • 3,895
  • 6
  • 31
  • 45
11
votes
6 answers

Is int (Int32) considered an object in .NET or a primitive (not int?)?

Is int (aka Int32) an object , or a primitive in .NET (I'm not asking regarding int?)? I hit F12 on the saved word int and got : public struct Int32 : IComparable, IFormattable, IConvertible, IComparable, IEquatable { ... } It doesn't…
JAN
  • 21,236
  • 66
  • 181
  • 318
11
votes
3 answers

Why is it not possible use primitive types with polymorphic return types?

Consider the following two classes: public interface Foo { public T moo(); } public class IntFoo implements Foo { public int moo() { return 0; } } This code will produce an error at publicintmoo, saying that int…
Clashsoft
  • 11,553
  • 5
  • 40
  • 79