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
-2
votes
1 answer

Diffie-Hellman -- Primitive root mod n -- cryptography question

In the below snippet, please explain starting with the first "for" loop what is happening and why. Why is 0 added, why is 1 added in the second loop. What is going on in the "if" statement under bigi. Finally explain the modPow method. Thank you in…
-2
votes
5 answers

How to create an ArrayList of arrays of primitives

This may sound confusing, but I'd like to make an ArrayList which contains int[]. Would an int[] be considered an object, or is it treated the same way as a primitive and require wrapping and unwrapping the values. For example: ArrayList
greatmastermario
  • 87
  • 1
  • 1
  • 11
-2
votes
1 answer

How to create shaders for GLES2

I am new to OpenGL ES 2, all my previous work was with OpenGL ES 1.1 but now I have to use OpenGL ES 2. I have found several tutorials and samples on this but I'm still confused. When I try to change the most common sample that draws a triangle on…
hamlatzis
  • 81
  • 10
-2
votes
1 answer

How to create a class for primitive data types

So I was wondering what would be the best way to create a class that can hold primitive data types? I want a class that basically can hold any data types, like when I use a constructor to create the class I can make it a float, double, or integer,…
me me
  • 778
  • 2
  • 7
  • 18
-3
votes
2 answers

array is not working as reference type ,do array come under reference data types in JavaScript

let names = ['mdv','venkatesh','nani'] // array methhods join let result = names.join('-'); console.log(result); o/p mdv-venkatesh-nani console.log(names); o/p ['mdv','venkatesh','nani'] I heard that array are the reference data types in…
-3
votes
1 answer

How to draw a textured sphere in XNA

I would like an example on how to draw a sphere, with texture on it (e.g. checkered), in modern XNA (as per MonoGame). Everything should happen programmatically (model and texture are generated, not loaded from files). Brief and tractable is a…
alamar
  • 18,729
  • 4
  • 64
  • 97
-3
votes
2 answers

Control return of Type of method in Java

I have a bean with many get but i want to create a generic method that takes this bean and controls the types of the return for its get. How i can say (boolean method??) that a get method return a primitive data or an Object? class A { int one;…
Alex
  • 111
  • 1
  • 13
-3
votes
3 answers

Concatenation of Boolean and Int

Why can't i do this? I understand that concatenation of a int and a string or with boolean,(true or false) is possible, but not an addition of boolean with an int. What exactly happens when u add a int with a boolean? Why does it show an…
Jayeloh
  • 13
  • 3
-3
votes
3 answers

Is it ok to use increment operators with any primitive type?

We all know that int++ will increase the variable value by 1, that is to say: int number = 0; int temp = number + 1; number = temp; This is allowed by the other primitive types too: double number = 0D; number++; So, I was wondering if the code…
spongebob
  • 8,370
  • 15
  • 50
  • 83
-4
votes
1 answer

Collect primitive array values into a collection of type Map

How can I convert an array of primitive int, long, or double values into a collection of type Map? import java.util.*; import java.util.function.*; import java.util.stream.*; public class PrimitiveStreamCollection { private static final…
Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
-4
votes
2 answers

How to manually free primitive variables?

I understand that in Java, we usually do not need to worry about deleting variables manually since garbage collection can take care of that. However, in some situations, we need to free an object before garbage collection takes effect in order to…
Chao Zhang
  • 15
  • 2
-4
votes
1 answer

C - Need explanation on printf options' behavior

Hi I have a double variable named outputSampleRate with value 0x41886a0000000000 I'm trying different combination of printf options and I get very confused by the output. Here is the code: printf("\n\noutputSampleRate 0x%16x \n",…
KKsan
  • 147
  • 1
  • 1
  • 8
-4
votes
2 answers

C - Unsigned long long to double on 32-bit machine

Hi I have two questions: uint64_t vs double, which has a higher range limit for covering positive numbers? How to convert double into uint64_t if only the whole number part of double is needed. Direct casting apparently doesn't work due to how…
KKsan
  • 147
  • 1
  • 1
  • 8
-5
votes
3 answers

Array repeated elements

I am trying to ask a user to input elements, but if the user inputs a repeated element my method should return false. So far this is what I have... Thank you in advance! public boolean setGuess(int index, int value) // required by instructor { …
-5
votes
1 answer

How to manipulate text in the middle of a string?

How can I concatenate a word within the string at a particular index using Python? For example:- In the string, "Delhi is the capital of India." I need to concatenate '123' before and after 'the'. The output should be:- "Delhi is 123the123…
1 2 3
65
66