Reference.Cast History

April 16, 2007, at 06:09 PM by Paul Badger -
Changed line 31 from:
to:
April 16, 2007, at 04:54 AM by David A. Mellis -

Parameters:

type: any variable type (e.g. int, float, byte)

variable: any variable or constant

Changed lines 27-32 from:

Parameters:

type: any variable type (e.g. int, float, byte)

variable: any variable or constant

to:

Note

When casting from a float to an int, the value is truncated not rounded. So both `(int) 3.2` and `(int) 3.7` are 3.

April 16, 2007, at 04:53 AM by David A. Mellis -
Changed lines 3-6 from:

Description:

The cast operator traslates one variable type into another and forces calculations to be performed in the cast type.

to:

Description

The cast operator translates one variable type into another and forces calculations to be performed in the cast type.

Changed lines 13-14 from:

[@int i;

to:

[@ int i;

Changed lines 16-17 from:

f = (float)i * 10

to:

f = 3.6; i = (int) f; // now i is 3

Deleted lines 26-36:

Example Code

```int x;
float f;

f = i / 2;        // f contains 0 - integer math can't hold fraction
f = (float)i / 2; // f contains .5 - cast forces floating point math on right side of equation

```

April 16, 2007, at 04:48 AM by David A. Mellis -
Changed lines 9-10 from:

(variableType1)variableType2

to:

(type)variable

Changed lines 21-24 from:

variableType1: any variable type

variableType2: any variable type

to:

type: any variable type (e.g. int, float, byte)

variable: any variable or constant

April 15, 2007, at 11:38 PM by Paul Badger -
Changed line 36 from:
to:
April 15, 2007, at 11:36 PM by Paul Badger -
Changed lines 33-36 from:

@]

to:
April 15, 2007, at 11:35 PM by Paul Badger -
Changed line 16 from:

f = (float)i

to:

f = (float)i * 10

Changed lines 31-32 from:

f = i / 2; // f contains 0 - integer math can't hold fraction f = (float)i / 2; f contains .5 - cast forces floating point math on right side of equation

to:

f = i / 2; // f contains 0 - integer math can't hold fraction f = (float)i / 2; // f contains .5 - cast forces floating point math on right side of equation

April 15, 2007, at 11:33 PM by Paul Badger -
Changed lines 31-32 from:

f = i / 2; f = (float)i

to:

f = i / 2; // f contains 0 - integer math can't hold fraction f = (float)i / 2; f contains .5 - cast forces floating point math on right side of equation

April 15, 2007, at 11:30 PM by Paul Badger -
Changed lines 9-10 from:

(variable type)variable

to:

(variableType1)variableType2

Changed line 13 from:

[@int x;

to:

[@int i;

@]

Parameters:

variableType1: any variable type

variableType2: any variable type

Example Code

[@int x; float f;

f = i / 2; f = (float)i

April 15, 2007, at 11:27 PM by Paul Badger -
Changed line 13 from:

int x;

to:

[@int x;

@]

April 15, 2007, at 11:26 PM by Paul Badger -
Changed lines 7-16 from:

to:

Syntax

(variable type)variable

Example

int x; float f;

f = (float)i

April 15, 2007, at 11:19 PM by Paul Badger -
Changed line 7 from:

to:

Syntax

April 15, 2007, at 11:19 PM by Paul Badger -