Thursday, May 29, 2008

E+3 Part 2

To convert from scientific notion to regular number, take the number before the E (E stands for exponent) and multiply it by 10 to raised to the power after the + or – sign. For example 3.4E+38, you would do the following arithmetic.
1.4 X 10 power 38

Note

Scientic notation provides a shortcut way of representing a range of numbers, but you lose some accuracy when you use because it does not allow for an extended amount of accuracy.

Wednesday, May 28, 2008

Java’s Fundamental Data Type

What is E+3 all about?

For the floating point and long double data type, the range is usually expressed in scientific notion. The scientific notion is actually an easier way to represent decimal data. It would actually require 34 follow by 4931 to represent one extreme of the range. This would really eat up a great chunk of memory that we have!

Monday, May 26, 2008

Non-numerical Literals 2

In C, a string literal represents an array of characters (the char primitive data type). However, as you will learn soon, Java does not follow suit. The following code provides some examples of the use of a string literal and the \t escape characters:

“This is a test”
“This is V test”

The first line above simple prints out the statement “This is a test.” The second line prints out the same thing, but places a tab where the \t is so, when printed, it will look something like “ This is a \test.”

Sunday, May 25, 2008

Non-Numerical Literals 2

\b Backspace
\f Form Feed
\n New line
\t Tab
\ Backslash
\’ Single quote
\” Double quote

You worked with string literal, the second major non-numerical literals, to print statements on the screen in the example in the last chapter. String literals are merely collections of character literals. Java stores string literals in a more complex type known as string object.

Friday, May 23, 2008

Non-Numerical Literals

Non-Numerical Literals

There are two major non-numerical literals in Java. The first, a character literal, represents a single character surrounded by quotations. Some characters are not so obvious or simply cannot be encased in quotations. That is where character escapes come in. The following post is a list of commonly used escape characters to print the not-so –obvious values:

Tuesday, May 20, 2008

Literals Notes 2

Literals Notes 2

Floating-point types also let you specify scientific notation by using the letter e or (E) to represent the exponential power. For example, the value 2.54 x 10 power 5 represented in Java is 2.54e5 or 2.54e5f housed in the float type.

Unlike C and C ++, Java has Booleans literals, Java Booleans represent either the non-numerical value true or false.

Monday, May 19, 2008

Literals Notes

Appended letters for specifying a particular data type when using literals are not case sensitive. For example, 100001 and 10000L both specify this literal to be a numerical type long. Extremely large values utilize the integer data type long. Floating-point values are automatically assumed to be a type double. However if you wish to use the smaller floating-point type float, then you need to append a letter “f” to represent that data type 2.313f.

Sunday, May 18, 2008

Numerical Literals

In Java programs, numerical literals represent quantitative values, Java supports several different numerical systems, including octal (a numbering system with a base of 8) and hexadecimal (using a base of 16). If needed, you can specify the literal to be long by appending the letter “L”: 24050000L. An int is the default type used for integer literals.

Thursday, May 15, 2008

Literal 2

Literal 2

Data types, discussed later in the chapter are values (a.k.a variables) that represent or hold other values. This is very similar to algebra, where x can be more than just x; x could be 2, square root of -5, or the gross national product. As you will learn later, Java has a specific set of data types for certain values.

Monday, May 12, 2008

Literal

Literal

A literal is any value expressed as itself. There are several types of literals; numerical literals, including integers, floating-point values, and Booleans; and non-numerical literals, including characters and multiple literals (known as string literals).

Sunday, May 11, 2008

Getting A First Sip In Java

For a moment, let’s leave the theoretical world behind and get our hands dirty with Visual J++ by creating a very simple Java program in Visual J++.

To create any program in Visual J++, follow these 3 simple steps:

Write the program. (Later on you will learn tips and tricks to let Visual J++ write parts of your programs for you.)
Compile or build the code into an executable format.
Execute program.