primitive

What makes the availability of both primitive and object-wrapped values in JavaScript useful?

I wrote a blog post a while ago detailing how the availability of both primitive and object-wrapped value types in JavaScript (for things such as Number, String and Boolean) causes trouble, including but not limited to type-casting to a boolean (e.g. object-wrapped NaN, "" and false actually type-cast to true). My question is, with all ...

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 advance for meaningful replies. public static boolean isPrimitive(BigInteger m, BigInteg...

declaring/initializing primitives equal to creating new objects

is declaring/initializing primitives the same as creating new objects? from what i know when we create primitives, we also creating wrapper classes for them. im implementing on java btw. ...

Why does autoboxing in Java allow me to have 3 possible values for a boolean?

Reference: http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html "If your program tries to autounbox null, it will throw a NullPointerException." javac will give you a compile-time error if you try to assign null to a boolean. makes sense. assigning null to a Boolean is a-ok though. also makes sense, i guess. but let'...

C++: Unsigned negative primitives?

In C++ we can make primitives unsigned. But they are always positive. Is there also a way to make unsigned negative variables? I know the word unsigned means "without sign", so also not a minus (-) sign. But I think C++ must provide it. ...

Simple question on Java primitives

float f = 1; float g = 1.1; float h = 1.1f; second line has compilation error. While rest of line do not have compilation error.Please suggest. First line is working fine without suffix f and third line is working with suffix f. ...

setting value to the instance of primitive types

I have a function which performs some operation i.e. fetches some data from database. The generic it takes is primitive type always i.e. int, char, bool, string etc. I can easily create its instance. But I can't set the value that I have fetched from database to this instance. public T PerformOperation<T>() { object instance = (...

XNA - Drawing Quads (and primitives) in right order

Hi there, I'm fairly new to 3D-stuff in XNA and unfortunately I have encountered a problem I can't find the solution for. (Don't even know what the problem is). To cut it short: I am drawing quads in my game using: effect.World = Matrix.Identity * Matrix.CreateRotationX(Rotation.X) * Matrix.CreateRotatio...

10 LISP primitives analogous to 5 axioms of Euclidean geometry?

LISP can be built from ten primitives: The primitives are: atom, quote, eq, car, cdr, cons, cond, lambda, label, apply. Apparently these are equivalent to the 5 axioms of Euclidean geometry. http://hyperpolyglot.wikidot.com/lisp Can anyone explain how they are equivalent? ...

Position 3d objects in xna

I'm pretty new to xna development and want to position the Cubes from the Primitives3D sample by passing a position vector to the constructor .. unfortunatly it does not work .. instead it is just spinning arround.. Thats how i modified the code of the cubeprimitive class: public class CubePrimitive : GeometricPrimitive { public ...

The inheritance of javascript

Maybe this question is easy,but I can't understand now. String.prototype.self=function() { return this; } var s="s"; alert("s".self()=="s".self()) //false; alert(s.self()==s.self()) //false; If you know the reason, please tell me why the result is "false". ...

Primitives Types in Java

Why to use primitive types in java instead of Wrapper classes? I want to know that already we have wrapper classes in java, then why we need to use primitive types? What are the importance of primitive types in java? ...

How can i include (constant) primitive data tables in a class?

I have some classes that need a bunch of data tables to do their work (basically arrays of primitives, byte[], short[], int[] and float[]). Some of the tables are relatively large. Initializing them in the code blows up the class file, and in some cases it also exceeds the size limit for the class initializer. Currently i have stored t...

Behind the scenes, what's happening with decimal value type in C#/.NET?

How is the decimal type implemented? Update It's a 128-bit value type (16 bytes) 1 sign bit 96 bits (12 bytes) for the mantissa 8 bits for the exponent remaining bits (23 of them!) set to 0 Thanks! I'm gonna stick with using a 64-bit long with my own implied scale. ...

Using for-each over an array of Objects - "Integer[] array" - Why Does "for(int i : array)" Work?

Basically the title says it all. Why does using a primitive data type work in the second "for-each" loop when I am looping over an array of objects. Is there a casting back to the primitive equivalent of the Integer object occurring behind the scenes? import java.util.Arrays; import java.util.Collections; public class CodeTestingClas...

int vs float arithmetic efficiency in Java

Hi all. 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 improve if I convert all weight to ints? Is int arithmetic operations are faster in J...

How many primitives does it take to build a LISP machine? Ten, seven or five?

On this site they say there are 10 LISP primitives. The primitives are: atom, quote, eq, car, cdr, cons, cond, lambda, label, apply. http://hyperpolyglot.wikidot.com/lisp#ten-primitives Stevey reckons there are seven (or five): Its part of the purity of the idea of LISP: you only need the seven (or is it five?) primitives to build ...

What is the `isolate primitive` mentioned in the documentation of the "cereal" package?

There is an extensive collection of unique words in on the Haskell repository, cabal, (very slight exaggeration). Anyway today's term is isolate primitive. What is an isolate primitive? How does it compare to a non-isolate primitive? Unfortunately, I don't have the background to know most of the Haskell parlance, and Google isn't helping...

How to implement floor, ceil and round in LLVM bitcode?

Good day overflowers. I'm writing the math functions for a small LLVM-based programming language, and I'm currenly stumped by how to implement the common rounding fuctions floor, ceil and round (to even). Firstly because i haven't found any algorithm descriptions for these functions, secondly because I'm not familiar with what capabilit...

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 primitives" (although I'm open to an argument about type predicates like numberp) How would you ...