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

Choosing 2D framework based on Stage3D

I want to use Stage3D to speed up my 2D graphics rendering (and perhaps add a shader or two). I use Flixel at the moment; Flixel offers pretty much everything I want from game framework, aside from not utilizing Stage3D. So, I don't necessarily need…
Luka Mikec
  • 417
  • 4
  • 20
-1
votes
4 answers

Passing dynamic primitive type (int) to a method

In Java, the output of s is 0. I do not understand why and would it be possible to somehow get the correct value of s (1000 here)? public static void main(String args) { int s = 0; List list = getList(s); System.out.println("s =…
Sophie Sperner
  • 4,428
  • 8
  • 35
  • 55
-1
votes
1 answer

Defualt id generated by Eclipse has char inside the value, and the variable type is long. How?

This is not new, but I wonder how come java can assign something like, 1L to long datatype. private static final long serialVersionUID = 1L; where the definition of long data type is, long: The long data type is a 64-bit signed two's complement…
TeaCupApp
  • 11,316
  • 18
  • 70
  • 150
-1
votes
2 answers

How would one code test and set behavior without a special hardware instruction?

Most of the implementations I find require a hardware instruction to do this. However I strongly doubt this is required (if it is, I can't figure out why...)
vlee
  • 1,369
  • 3
  • 14
  • 23
-2
votes
1 answer

How are we able to call a function to typecast on a custom type even when a method is not defined to it

How could we call a function on hello as hello(0) below even though we have no function defined on hello? package main import "fmt" type hello int32 func main() { x := hello(0) //converting int to int32 fmt.Printf("Type : %T, Value:…
Rajesh
  • 1,514
  • 2
  • 14
  • 15
-2
votes
2 answers

Why do these two cases show different results for Array elements in Java?

Here, the value of Array arr elements do not change after changing values of a and b. int a=10, b=20; int[] arr = {a,b}; a = 20; b = 10; System.out.println("a = " + a); // a=20 System.out.println("b = " + b); //…
Seth
  • 3
  • 2
-2
votes
1 answer

Garbage-collected languages with efficient numeric data types

I am searching for a language/library (preferably JVM-based) that handles numeric values (integer and floating point numbers) in both convenient and efficient manner. Convenient: supported by the collection framework and generics. Efficient:…
-2
votes
3 answers

Why is it that I can declare a numerical variable as a double but still use .nextInt()?

Okay, I'm new to coding so I am unfamiliar with everything. Here's my question: Why is it that .nextInt(); will process a double even though the name is .nextInt();? double max = scan.nextInt(); This works, but why?
CelineDion
  • 906
  • 5
  • 21
-2
votes
1 answer

Why does the method with byte parameter calls the method with short, why not int?

class Practice { public static void aMethod (int val) { System.out.println("int"); } public static void aMethod (short val) { System.out.println("short"); } public static void aMethod (Object val) { System.out.println("object"); } public…
valer
  • 119
  • 3
-2
votes
3 answers

javascript primitives vs object references

I've been using JavaScript for years and this one has me stumped. As I understood things, when defining a var, one of two things will happen: If the expression is a primitive, var is defined as a new instance of that primitive with no reference to…
Cliff
  • 697
  • 8
  • 19
-2
votes
1 answer

Java primitive data fields in object wrappers

I was looking through the documentation for primitive wrappers in Java. While I understand the utility of all the extra functionality provided by the methods, I don't seem to understand how the object stores the primitive in the first place. There…
Abhinav Vishak
  • 361
  • 1
  • 5
  • 17
-2
votes
2 answers

Boolean represented as text or number?

I am creating an application with three data types: Number Text Date The app is geared towards a non-technical user who would know what a date is, or what a number is (without caring/knowing if it's an int, decimal, float, etc.). My question is,…
David542
  • 104,438
  • 178
  • 489
  • 842
-2
votes
2 answers

i am getting true and false output why?

I know int range is -2147483648 to +2147483647 but here I'm getting output as true and false. Why? Actually i1 and i2 point to the same object, so output is true. I can understood but i3 and i4 also pointing to same object but I got output as false.…
Mahi
  • 1
  • 2
-2
votes
1 answer

How the output of the the code below is '1'?

I tried the same code by replacing default values in the code below, I got '-1'. But the actual output is '1'. How??? int i = (byte) + (char) - (int) + (long) - 1; System.out.println(i);
-2
votes
1 answer

Create a function that can generate array with only prime numbers

I was told in a JavaScript interview to create a function getPrime(n) to generate an array with only primitive numbers in it. The number in array has to be between 0 and n. How to write it correctly?
user2734550
  • 952
  • 1
  • 12
  • 35