expanded class REAL

All features

Actually, REAL is a just a short-hand for REAL_64 (64 bits floating point).

Direct parents

conformant parents

REAL_GENERAL

Known children

conformant children

REAL_64

Summary

exported features

Conversions:

Conversions:

Object Printing:

Maths functions:

Miscellaneous:

Details

force_to_real_32: REAL_32
force_to_integer_32: INTEGER
force_to_integer_64: INTEGER_64
zero: REAL

Neutral element for "+" and "-".

one: REAL

Neutral element for "*" and "/".

hash_code: INTEGER

The hash-code value of Current.

ensure

  • good_hash_value: Result >= 0

mantissa_bits: INTEGER_8

Give the number of bits, corresponding to the mantissa, in the binary representation of the real number.

exponent_bits: INTEGER_8

Give the number of bits, corresponding to the exponent, in the binary representation of the real number.

sprintf (buffer: NATIVE_ARRAY [E_][CHARACTER], mode: CHARACTER, f: INTEGER, value: REAL)

Put in the buffer a viewable version of the value using mode with f digits for the fractional part. Assume the buffer is large enougth.

require

  • mode = 'f' xor mode = 'e'
  • f >= 0

is_equal (other: REAL): BOOLEAN

Is other attached to an object considered equal to current object ?

require

  • other /= Void

ensure

  • trichotomy: Result = (not (Current < other) and not (other < Current))
  • commutative: generating_type = other.generating_type implies Result = other.is_equal(Current)
  • Result implies hash_code = other.hash_code

+: REAL

Unary plus of Current.

-: REAL

Unary minus of Current.

+ (other: REAL): REAL

Sum with other (commutative).

- (other: REAL): REAL

Result of substracting other.

* (other: REAL): REAL

Product by other.

/ (other: REAL): REAL

Division by other.

require

  • other /= Void
  • divisible(other)

^ (e: INTEGER): REAL

Raise Current to e-th power (see also pow).

< (other: REAL): BOOLEAN

Is Current strictly less than other?

See also >, <=, >=, min, max.

require

  • other_exists: other /= Void

ensure

  • asymmetric: Result implies not (other < Current)

<= (other: REAL): BOOLEAN

Is Current less than or equal other?

See also >=, <, >, min, max.

require

  • other_exists: other /= Void

ensure

  • definition: Result = (Current < other or is_equal(other))

> (other: REAL): BOOLEAN

Is Current strictly greater than other?

See also <, >=, <=, min, max.

require

  • other_exists: other /= Void

ensure

  • definition: Result = (other < Current)

>= (other: REAL): BOOLEAN

Is Current greater than or equal than other?

See also <=, >, <, min, max.

require

  • other_exists: other /= Void

ensure

  • definition: Result = (other <= Current)

abs: REAL
is_not_a_number: BOOLEAN

Also known as NaN in IEEE-754.

is_infinity: BOOLEAN

Is either plus or minus infinity?

is_zero: BOOLEAN

Is either -0.0 or +0.0 ?

~= (other: REAL): BOOLEAN

Is Current near equal to other.

is_subnormal: BOOLEAN

Is it too small to be represented in normalized format.

ensure

  • Result = (Current = 0.0) or else Current = -0.0

is_normal: BOOLEAN

The most general situation (see ensure).

ensure

  • Result = not (is_subnormal or is_infinity or is_not_a_number)

divisible (other: REAL): BOOLEAN

May Current be divided by other ?

require

  • other /= Void

frozen rounded: REAL

Round to nearest integer away from zero.

frozen floor: REAL

Largest integral value no greater than Current.

frozen ceiling: REAL

Smallest integral value no smaller than Current.

to_string: STRING

Convert Current into a new allocated STRING using 6 as the default number of digits for the fractional part. Exemple: (1.5).to_string will return "1.500000".

Note: see also to_string_format, to_string_scientific as well as append_in to save memory.

to_string_format (f: INTEGER): STRING

Convert Current into a new allocated STRING using f digits for fractional part. Exemple: (1.5).to_string_format(2) will return "1.50".

Note: see also to_string_scientific, to_string as well as append_in_format to save memory.

require

  • f >= 0

to_string_scientific (f: INTEGER): STRING

Convert Current into a new allocated STRING, using the scientific notation with f digits for the fractional part. Exemple: (155.5).to_string_scientific(4) will return "1.5550e+02".

Note: see also to_string, to_string_format as well as append_in_scientific to save memory.

append_in (buffer: STRING)

Append the equivalent of to_string at the end of buffer. Thus you can save memory because no other STRING is allocate for the job.

require

  • buffer /= Void

append_in_format (str: STRING, f: INTEGER)

Append the equivalent of to_string_format at the end of buffer. Thus you can save memory because no other STRING is allocate for the job.

require

  • str /= Void
  • f >= 0

append_in_scientific (str: STRING, f: INTEGER)

Append the equivalent of to_string_scientific at the end of buffer. Thus you can save memory because no other STRING is allocate for the job.

require

  • str /= Void
  • f >= 0

out_in_tagged_out_memory

Append terse printable represention of current object in tagged_out_memory.

ensure

  • not_cleared: tagged_out_memory.count >= old tagged_out_memory.count
  • append_only: (old tagged_out_memory.twin).is_equal(tagged_out_memory.substring(1, old tagged_out_memory.count))

fill_tagged_out_memory

Append a viewable information in tagged_out_memory in order to affect the behavior of out, tagged_out, etc.

frozen sqrt: REAL

Square root of Current.

require

  • Current >= 0.0

frozen sin: REAL

Sine of Current.

frozen cos: REAL

Cosine of Current.

frozen tan: REAL

Tangent of Current.

frozen asin: REAL

Arc Sine of Current.

frozen acos: REAL

Arc Cosine of Current.

frozen atan: REAL

Arc Tangent of Current.

frozen atan2 (x: REAL): REAL

Arc Tangent of Current / x.

frozen sinh: REAL

Hyperbolic Sine of Current.

frozen cosh: REAL

Hyperbolic Cosine of Current.

frozen tanh: REAL

Hyperbolic Tangent of Current.

frozen exp: REAL

Exponential of Current.

frozen log: REAL

Natural Logarithm of Current.

frozen log10: REAL

Base-10 Logarithm of Current.

frozen pow (e: REAL): REAL

Current raised to the power of e (ANSI C pow).

sign: INTEGER_8

Sign of Current (0 -1 or 1).

ensure

  • -1 <= Result
  • Result <= 1

sprintf_buffer: NATIVE_ARRAY [E_][CHARACTER]
deferred is_equal (other: REAL): BOOLEAN

Is other attached to an object considered equal to current object ?

require

  • other /= Void

ensure

  • Result implies hash_code = other.hash_code
  • commutative: generating_type = other.generating_type implies Result = other.is_equal(Current)

is_equal (other: REAL): BOOLEAN

Is other attached to an object considered equal to current object ?

require

  • other /= Void

ensure

  • trichotomy: Result = (not (Current < other) and not (other < Current))
  • commutative: generating_type = other.generating_type implies Result = other.is_equal(Current)

in_range (lower: REAL, upper: REAL): BOOLEAN

Return True if Current is in range [lower..upper]

See also min, max, compare.

ensure

  • Result = (Current >= lower and Current <= upper)

compare (other: REAL): INTEGER

If current object equal to other, 0 if smaller, -1; if greater, 1.

See also min, max, in_range.

require

  • other_exists: other /= Void

ensure

  • equal_zero: Result = 0 = is_equal(other)
  • smaller_negative: Result = -1 = (Current < other)
  • greater_positive: Result = 1 = (Current > other)

three_way_comparison (other: REAL): INTEGER

If current object equal to other, 0 if smaller, -1; if greater, 1.

See also min, max, in_range.

require

  • other_exists: other /= Void

ensure

  • equal_zero: Result = 0 = is_equal(other)
  • smaller_negative: Result = -1 = (Current < other)
  • greater_positive: Result = 1 = (Current > other)

min (other: REAL): REAL

Minimum of Current and other.

See also max, in_range.

require

  • other /= Void

ensure

  • Result <= Current and then Result <= other
  • compare(Result) = 0 or else other.compare(Result) = 0

max (other: REAL): REAL

Maximum of Current and other.

See also min, in_range.

require

  • other /= Void

ensure

  • Result >= Current and then Result >= other
  • compare(Result) = 0 or else other.compare(Result) = 0