Native floating point numbers.

Corresponds to C float.

Introduced properties

fun abs: Float

core :: Float :: abs

Returns the absolute value of self.
fun acos: Float

core :: Float :: acos

Computes the arc cosine of self.
fun angle_lerp(a: Float, b: Float): Float

core :: Float :: angle_lerp

Linear interpolation of between the angles a and b, in radians
fun angle_normalize: Float

core :: Float :: angle_normalize

Normalize the self angle in radians to be within [-pi .. pi[
fun asin: Float

core :: Float :: asin

Computes the arc sine of self.
fun atan: Float

core :: Float :: atan

Computes the arc tangent of self.
fun ceil: Float

core :: Float :: ceil

assert 1.1.ceil == 2.0
fun cerp(a: Float, a_handle: Float, b_handle: Float, b: Float): Float

core :: Float :: cerp

Cubic Bézier interpolation between a and b with two handles using self as weight
fun cos: Float

core :: Float :: cos

Computes the cosine of self (expressed in radians).
fun exp: Float

core :: Float :: exp

Returns e raised to self.
fun floor: Float

core :: Float :: floor

assert 1.1.floor == 1.0
fun hypot_with(b: Float): Float

core :: Float :: hypot_with

Returns the euclidean distance from b.
fun is_approx(other: Float, precision: Float): Bool

core :: Float :: is_approx

Compare float numbers with a given precision.
fun is_inf: Int

core :: Float :: is_inf

Is the float an infinite value
fun is_nan: Bool

core :: Float :: is_nan

Returns true is self is not a number.
fun lerp(a: Float, b: Float): Float

core :: Float :: lerp

Linear interpolation between a and b using self as weight
fun log: Float

core :: Float :: log

Natural logarithm of self.
fun log_base(base: Float): Float

core :: Float :: log_base

Logarithm of self to base base.
fun pow(e: Float): Float

core :: Float :: pow

Returns self raised at e power.
fun qerp(a: Float, handle: Float, b: Float): Float

core :: Float :: qerp

Quadratic Bézier interpolation between a and b with an handle using self as weight
fun rand: Float

core :: Float :: rand

Returns a random Float in [0.0 .. self[.
fun round: Float

core :: Float :: round

Rounds the value of a float to its nearest integer value
fun sin: Float

core :: Float :: sin

Computes the sine of self (expressed in radians).
fun sleep

core :: Float :: sleep

Sleep approximately self seconds
fun sqrt: Float

core :: Float :: sqrt

Returns the non-negative square root of self.
fun tan: Float

core :: Float :: tan

Computes the cosine of x (expressed in radians).
fun to_hexa_exponential_notation: String

core :: Float :: to_hexa_exponential_notation

Returns the hexadecimal (String) representation of self in exponential notation
fun to_precision(decimals: Int): String

core :: Float :: to_precision

String representation of self with the given number of decimals
fun to_sci: String

core :: Float :: to_sci

Return the representation of self, with scientific notation

Redefined properties

redef intern fun !=(i: nullable Object): Bool

core $ Float :: !=

Have self and other different values?
redef intern fun *(i: OTHER): OTHER

core $ Float :: *

Multiplication of self with i
redef intern fun +(i: OTHER): OTHER

core $ Float :: +

Addition of self with i
redef intern fun -(i: OTHER): OTHER

core $ Float :: -

Substraction of i from self
redef intern fun /(i: OTHER): OTHER

core $ Float :: /

Division of self with i
redef intern fun <(i: OTHER): Bool

core $ Float :: <

Is self lesser than other?
redef intern fun <=(i: OTHER): Bool

core $ Float :: <=

not other < self
redef fun <=>(other: OTHER): Int

core $ Float :: <=>

-1 if <, +1 if > and 0 otherwise
redef intern fun ==(i: nullable Object): Bool

core $ Float :: ==

Have self and other the same value?
redef intern fun >(i: OTHER): Bool

core $ Float :: >

other < self
redef intern fun >=(i: OTHER): Bool

core $ Float :: >=

not self < other
redef type OTHER: Float

core $ Float :: OTHER

What self can be compared to?
redef type SELF: Float

core $ Float :: SELF

Type of this instance, automatically specialized in every class
redef fun accept_json_serializer(v: JsonSerializer)

json :: serialization_write $ Float :: accept_json_serializer

Refinable service to customize the serialization of this class to JSON
redef fun accept_msgpack_serializer(v: MsgPackSerializer)

msgpack :: serialization_write $ Float :: accept_msgpack_serializer

Hook to customize the serialization of this class to MessagePack
redef fun add(other: Numeric): Numeric

core :: numeric $ Float :: add

Universal + with any Numeric
redef fun add_to_bundle(bundle: NativeBundle, key: JavaString)

android :: bundle $ Float :: add_to_bundle

Called by []= to dynamically choose the appropriate method according
redef fun core_serialize_to(v: Serializer)

noise :: noise $ Float :: core_serialize_to

Actual serialization of self to serializer
redef fun div(other: Numeric): Numeric

core :: numeric $ Float :: div

Universal / with any Numeric
redef init from_deserializer(v: Deserializer)

noise :: noise $ Float :: from_deserializer

Create an instance of this class from the deserializer
redef fun is_between(c: OTHER, d: OTHER): Bool

core $ Float :: is_between

c <= self <= d
redef fun max(other: OTHER): OTHER

core $ Float :: max

The maximum between self and other (prefers self if equals).
redef fun min(c: OTHER): OTHER

core $ Float :: min

The minimum between self and c (prefer self if equals)
redef fun mul(other: Numeric): Numeric

core :: numeric $ Float :: mul

Universal * with any Numeric
redef intern fun object_id: Int

core $ Float :: object_id

An internal hash code for the object based on its identity.
redef intern fun output

core $ Float :: output

Display self on stdout (debug only).
redef fun sub(other: Numeric): Numeric

core :: numeric $ Float :: sub

Universal - with any Numeric
redef intern fun to_b: Byte

core $ Float :: to_b

The byte equivalent of self
redef fun to_bi: BigInt

gmp :: gmp $ Float :: to_bi

The BigInt equivalent of self
redef fun to_f: Float

core $ Float :: to_f

The float equivalent of self
redef intern fun to_i: Int

core $ Float :: to_i

The integer part of self.
redef intern fun to_i16: Int16

core :: fixed_ints $ Float :: to_i16

The Int16 equivalent of self
redef intern fun to_i32: Int32

core :: fixed_ints $ Float :: to_i32

The Int32 equivalent of self
redef intern fun to_i8: Int8

core :: fixed_ints $ Float :: to_i8

The Int8 equivalent of self
redef fun to_jvalue(env: JniEnv): JValue

jvm :: jvm $ Float :: to_jvalue

redef fun to_r: Ratio

gmp :: gmp $ Float :: to_r

The Ratio equivalent of self
redef fun to_s: String

core :: abstract_text $ Float :: to_s

Pretty representation of self, with decimals as needed from 1 to a maximum of 3
redef intern fun to_u16: UInt16

core :: fixed_ints $ Float :: to_u16

The UInt16 equivalent of self
redef intern fun to_u32: UInt32

core :: fixed_ints $ Float :: to_u32

The UInt32 equivalent of self
redef intern fun unary -: OTHER

core $ Float :: unary -

Inverse of self
redef fun value_of(val: Numeric): OTHER

core $ Float :: value_of

The value of val in the domain of self
redef fun zero: OTHER

core $ Float :: zero

The value of zero in the domain of self

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
abstract fun *(i: OTHER): OTHER

core :: Numeric :: *

Multiplication of self with i
abstract fun +(i: OTHER): OTHER

core :: Numeric :: +

Addition of self with i
abstract fun -(i: OTHER): OTHER

core :: Numeric :: -

Substraction of i from self
abstract fun /(i: OTHER): OTHER

core :: Numeric :: /

Division of self with i
abstract fun <(other: OTHER): Bool

core :: Comparable :: <

Is self lesser than other?
fun <=(other: OTHER): Bool

core :: Comparable :: <=

not other < self
fun <=>(other: OTHER): Int

core :: Comparable :: <=>

-1 if <, +1 if > and 0 otherwise
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
fun >(other: OTHER): Bool

core :: Comparable :: >

other < self
fun >=(other: OTHER): Bool

core :: Comparable :: >=

not self < other
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type OTHER: Comparable

core :: Comparable :: OTHER

What self can be compared to?
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun abs: Float

core :: Float :: abs

Returns the absolute value of self.
protected fun accept_json_serializer(v: JsonSerializer)

serialization :: Serializable :: accept_json_serializer

Refinable service to customize the serialization of this class to JSON
protected fun accept_msgpack_attribute_counter(v: AttributeCounter)

serialization :: Serializable :: accept_msgpack_attribute_counter

Hook to customize the behavior of the AttributeCounter
protected fun accept_msgpack_serializer(v: MsgPackSerializer)

serialization :: Serializable :: accept_msgpack_serializer

Hook to customize the serialization of this class to MessagePack
fun acos: Float

core :: Float :: acos

Computes the arc cosine of self.
abstract fun add(other: Numeric): Numeric

core :: Numeric :: add

Universal + with any Numeric
protected fun add_to_bundle(bundle: NativeBundle, key: JavaString)

serialization :: Serializable :: add_to_bundle

Called by []= to dynamically choose the appropriate method according
fun angle_lerp(a: Float, b: Float): Float

core :: Float :: angle_lerp

Linear interpolation of between the angles a and b, in radians
fun angle_normalize: Float

core :: Float :: angle_normalize

Normalize the self angle in radians to be within [-pi .. pi[
fun asin: Float

core :: Float :: asin

Computes the arc sine of self.
fun atan: Float

core :: Float :: atan

Computes the arc tangent of self.
fun ceil: Float

core :: Float :: ceil

assert 1.1.ceil == 2.0
fun cerp(a: Float, a_handle: Float, b_handle: Float, b: Float): Float

core :: Float :: cerp

Cubic Bézier interpolation between a and b with two handles using self as weight
fun clamp(min: OTHER, max: OTHER): OTHER

core :: Comparable :: clamp

Constraint self within [min..max]
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun core_serialize_to(serializer: Serializer)

serialization :: Serializable :: core_serialize_to

Actual serialization of self to serializer
fun cos: Float

core :: Float :: cos

Computes the cosine of self (expressed in radians).
abstract fun div(other: Numeric): Numeric

core :: Numeric :: div

Universal / with any Numeric
fun exp: Float

core :: Float :: exp

Returns e raised to self.
fun floor: Float

core :: Float :: floor

assert 1.1.floor == 1.0
init from_deserializer(deserializer: Deserializer)

serialization :: Serializable :: from_deserializer

Create an instance of this class from the deserializer
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
fun hypot_with(b: Float): Float

core :: Float :: hypot_with

Returns the euclidean distance from b.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun is_approx(other: Float, precision: Float): Bool

core :: Float :: is_approx

Compare float numbers with a given precision.
fun is_between(c: OTHER, d: OTHER): Bool

core :: Comparable :: is_between

c <= self <= d
fun is_inf: Int

core :: Float :: is_inf

Is the float an infinite value
fun is_nan: Bool

core :: Float :: is_nan

Returns true is self is not a number.
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun is_zero: Bool

core :: Numeric :: is_zero

Is this the value of zero in its domain?
fun lerp(a: Float, b: Float): Float

core :: Float :: lerp

Linear interpolation between a and b using self as weight
fun log: Float

core :: Float :: log

Natural logarithm of self.
fun log_base(base: Float): Float

core :: Float :: log_base

Logarithm of self to base base.
fun max(other: OTHER): OTHER

core :: Comparable :: max

The maximum between self and other (prefers self if equals).
fun min(c: OTHER): OTHER

core :: Comparable :: min

The minimum between self and c (prefer self if equals)
protected fun msgpack_extra_array_items: Int

serialization :: Serializable :: msgpack_extra_array_items

Hook to request a larger than usual metadata array
abstract fun mul(other: Numeric): Numeric

core :: Numeric :: mul

Universal * with any Numeric
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun pow(e: Float): Float

core :: Float :: pow

Returns self raised at e power.
fun qerp(a: Float, handle: Float, b: Float): Float

core :: Float :: qerp

Quadratic Bézier interpolation between a and b with an handle using self as weight
fun rand: Float

core :: Float :: rand

Returns a random Float in [0.0 .. self[.
fun round: Float

core :: Float :: round

Rounds the value of a float to its nearest integer value
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
fun serialize_msgpack(plain: nullable Bool): Bytes

serialization :: Serializable :: serialize_msgpack

Serialize self to MessagePack bytes
fun serialize_to(serializer: Serializer)

serialization :: Serializable :: serialize_to

Serialize self to serializer
fun serialize_to_json(plain: nullable Bool, pretty: nullable Bool): String

serialization :: Serializable :: serialize_to_json

Serialize self to JSON
fun sin: Float

core :: Float :: sin

Computes the sine of self (expressed in radians).
fun sleep

core :: Float :: sleep

Sleep approximately self seconds
fun sqrt: Float

core :: Float :: sqrt

Returns the non-negative square root of self.
abstract fun sub(other: Numeric): Numeric

core :: Numeric :: sub

Universal - with any Numeric
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun tan: Float

core :: Float :: tan

Computes the cosine of x (expressed in radians).
abstract fun to_b: Byte

core :: Numeric :: to_b

The byte equivalent of self
fun to_bi: BigInt

core :: Numeric :: to_bi

The BigInt equivalent of self
abstract fun to_f: Float

core :: Numeric :: to_f

The float equivalent of self
fun to_hexa_exponential_notation: String

core :: Float :: to_hexa_exponential_notation

Returns the hexadecimal (String) representation of self in exponential notation
abstract fun to_i: Int

core :: Numeric :: to_i

The integer part of self.
fun to_i16: Int16

core :: Numeric :: to_i16

The Int16 equivalent of self
fun to_i32: Int32

core :: Numeric :: to_i32

The Int32 equivalent of self
fun to_i8: Int8

core :: Numeric :: to_i8

The Int8 equivalent of self
fun to_json: String

serialization :: Serializable :: to_json

Serialize self to plain JSON
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_precision(decimals: Int): String

core :: Float :: to_precision

String representation of self with the given number of decimals
fun to_pretty_json: String

serialization :: Serializable :: to_pretty_json

Serialize self to plain pretty JSON
fun to_r: Ratio

core :: Numeric :: to_r

The Ratio equivalent of self
fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun to_sci: String

core :: Float :: to_sci

Return the representation of self, with scientific notation
fun to_u16: UInt16

core :: Numeric :: to_u16

The UInt16 equivalent of self
fun to_u32: UInt32

core :: Numeric :: to_u32

The UInt32 equivalent of self
abstract fun unary -: OTHER

core :: Numeric :: unary -

Inverse of self
abstract fun value_of(val: Numeric): OTHER

core :: Numeric :: value_of

The value of val in the domain of self
abstract fun zero: OTHER

core :: Numeric :: zero

The value of zero in the domain of self
package_diagram core::Float Float serialization::DirectSerializable DirectSerializable core::Float->serialization::DirectSerializable core::Numeric Numeric core::Float->core::Numeric sqlite3::Sqlite3Data Sqlite3Data core::Float->sqlite3::Sqlite3Data serialization::Serializable Serializable serialization::DirectSerializable->serialization::Serializable core::Comparable Comparable core::Numeric->core::Comparable core::Object Object sqlite3::Sqlite3Data->core::Object ...serialization::Serializable ... ...serialization::Serializable->serialization::Serializable ...core::Comparable ... ...core::Comparable->core::Comparable ...core::Object ... ...core::Object->core::Object

Ancestors

interface Comparable

core :: Comparable

The ancestor of class where objects are in a total order.
interface Object

core :: Object

The root of the class hierarchy.
interface Serializable

serialization :: Serializable

Instances of this class can be passed to Serializer::serialize

Parents

interface DirectSerializable

serialization :: DirectSerializable

Instances of this class are not delayed and instead serialized immediately
interface Numeric

core :: Numeric

A numeric value supporting mathematical operations
interface Sqlite3Data

sqlite3 :: Sqlite3Data

A data type supported by Sqlite3

Class definitions

core $ Float
# Native floating point numbers.
# Corresponds to C float.
universal Float
	super Numeric

	redef type OTHER: Float

	redef fun object_id is intern
	redef fun ==(i) is intern
	redef fun !=(i) is intern
	redef fun output is intern

	redef fun <=(i) is intern
	redef fun <(i) is intern
	redef fun >=(i) is intern
	redef fun >(i) is intern

	redef fun +(i) is intern
	redef fun - is intern
	redef fun -(i) is intern
	redef fun *(i) is intern
	redef fun /(i) is intern

	redef fun to_i is intern
	redef fun to_f do return self
	redef fun to_b is intern

	redef fun zero do return 0.0
	redef fun value_of(val) do return val.to_f

	redef fun <=>(other)
	do
		if self < other then
			return -1
		else if other < self then
			return 1
		else
			return 0
		end
	end

	redef fun is_between(c, d)
	do
		if self < c or d < self then
			return false
		else
			return true
		end
	end

	# Compare float numbers with a given precision.
	#
	# Because of the loss of precision in floating numbers,
	# the `==` method is often not the best way to compare them.
	#
	# ~~~
	# assert 0.01.is_approx(0.02, 0.1)   == true
	# assert 0.01.is_approx(0.02, 0.001) == false
	# ~~~
	fun is_approx(other, precision: Float): Bool
	do
		assert precision >= 0.0
		return self <= other + precision and self >= other - precision
	end

	redef fun max(other)
	do
		if self < other then
			return other
		else
			return self
		end
	end

	redef fun min(c)
	do
		if c < self then
			return c
		else
			return self
		end
	end
end
lib/core/kernel.nit:517,1--599,3

core :: fixed_ints $ Float
redef class Float
	redef fun to_i8 is intern
	redef fun to_i16 is intern
	redef fun to_u16 is intern
	redef fun to_i32 is intern
	redef fun to_u32 is intern
end
lib/core/fixed_ints.nit:77,1--83,3

core :: math $ Float
redef class Float

	# Returns the non-negative square root of `self`.
	#
	#     assert 9.0.sqrt == 3.0
	#     #assert 3.0.sqrt == 1.732
	#     assert 1.0.sqrt == 1.0
	#     assert 0.0.sqrt == 0.0
	fun sqrt: Float `{ return sqrt(self); `}

	# Computes the cosine of `self` (expressed in radians).
	#
	#     #assert pi.cos == -1.0
	fun cos: Float `{ return cos(self); `}

	# Computes the sine of `self` (expressed in radians).
	#
	#     #assert pi.sin == 0.0
	fun sin: Float `{ return sin(self); `}

	# Computes the cosine of x (expressed in radians).
	#
	#     #assert 0.0.tan == 0.0
	fun tan: Float `{ return tan(self); `}

	# Computes the arc cosine of `self`.
	#
	#     #assert 0.0.acos == pi / 2.0
	fun acos: Float `{ return acos(self); `}

	# Computes the arc sine of `self`.
	#
	#     #assert 1.0.asin == pi / 2.0
	fun asin: Float `{ return asin(self); `}

	# Computes the arc tangent of `self`.
	#
	#     #assert 0.0.tan == 0.0
	fun atan: Float `{ return atan(self); `}

	# Returns the absolute value of `self`.
	#
	#     assert 12.0.abs == 12.0
	#     assert (-34.56).abs == 34.56
	#     assert -34.56.abs == -34.56
	fun abs: Float `{ return fabs(self); `}

	# Returns `self` raised at `e` power.
	#
	#     assert 2.0.pow(0.0) == 1.0
	#     assert 2.0.pow(3.0) == 8.0
	#     assert 0.0.pow(9.0) == 0.0
	fun pow(e: Float): Float `{ return pow(self, e); `}

	# Natural logarithm of `self`.
	#
	#     assert 0.0.log.is_inf == -1
	#     assert 1.0.log == 0.0
	fun log: Float `{ return log(self); `}

	# Logarithm of `self` to base `base`.
	#
	#     assert 100.0.log_base(10.0) == 2.0
	#     assert 256.0.log_base(2.0) == 8.0
	fun log_base(base: Float): Float do return log/base.log

	# Returns *e* raised to `self`.
	fun exp: Float `{ return exp(self); `}

	#     assert 1.1.ceil == 2.0
	#     assert 1.9.ceil == 2.0
	#     assert 2.0.ceil == 2.0
	#     assert (-1.5).ceil == -1.0
	fun ceil: Float `{ return ceil(self); `}

	#     assert 1.1.floor == 1.0
	#     assert 1.9.floor == 1.0
	#     assert 2.0.floor == 2.0
	#     assert (-1.5).floor == -2.0
	fun floor: Float `{ return floor(self); `}

	# Rounds the value of a float to its nearest integer value
	#
	#     assert 1.67.round == 2.0
	#     assert 1.34.round == 1.0
	#     assert -1.34.round == -1.0
	#     assert -1.67.round == -2.0
	fun round: Float `{ return round(self); `}

	# Returns a random `Float` in `[0.0 .. self[`.
	fun rand: Float `{
		if (nit_rand_seeded) return ((self)*nit_rand())/(NIT_RAND_MAX+1.0);
		return ((self)*rand())/(RAND_MAX+1.0);
	`}

	# Returns the euclidean distance from `b`.
	fun hypot_with(b: Float): Float `{ return hypotf(self, b); `}

	# Returns true is self is not a number.
	#
	# As `nan != nan`, `is_nan` should be used to test if a float is the special *not a number* value.
	#
	# ~~~
	# assert nan != nan # By IEEE 754
	# assert nan.is_nan
	# assert not 10.0.is_nan
	# ~~~
	fun is_nan: Bool `{ return isnan(self); `}

	# Is the float an infinite value
	# this function returns:
	#
	#  * 1 if self is positive infinity
	#  * -1 if self is negative infinity
	#  * 0 otherwise
	#
	# ~~~
	# assert 10.0.is_inf == 0
	# assert inf.is_inf == 1
	# assert (-inf).is_inf == -1
	# ~~~
	fun is_inf: Int do
		if native_is_inf then
			if self < 0.0 then return -1
			return 1
		end
		return 0
	end

	private fun native_is_inf: Bool `{ return isinf(self); `}

	# Linear interpolation between `a` and `b` using `self` as weight
	#
	# ~~~
	# assert  0.0.lerp(0.0, 128.0) == 0.0
	# assert  0.5.lerp(0.0, 128.0) == 64.0
	# assert  1.0.lerp(0.0, 128.0) == 128.0
	# assert -0.5.lerp(0.0, 128.0) == -64.0
	# ~~~
	fun lerp(a, b: Float): Float do return (1.0 - self) * a + self * b

	# Quadratic Bézier interpolation between `a` and `b` with an `handle` using `self` as weight
	#
	# ~~~
	# assert  0.00.qerp(0.0, 32.0, 128.0) == 0.0
	# assert  0.25.qerp(0.0, 32.0, 128.0) == 20.0
	# assert  0.50.qerp(0.0, 32.0, 128.0) == 48.0
	# assert  0.75.qerp(0.0, 32.0, 128.0) == 84.0
	# assert  1.00.qerp(0.0, 32.0, 128.0) == 128.0
	# ~~~
	fun qerp(a, handle, b: Float): Float do
		var p = self
		var i = 1.0 - p
		var r =     i*i * a +
			2.0*i*p * handle +
			    p*p * b
		return r
	end

	# Cubic Bézier interpolation between `a` and `b` with two handles using `self` as weight
	#
	# The Cubic Bézier interpolation is the most common one and use two control points.
	#
	# ~~~
	# assert  0.00.cerp(0.0, 32.0, 128.0, 64.0) == 0.0
	# assert  0.25.cerp(0.0, 32.0, 128.0, 64.0) == 32.5
	# assert  0.50.cerp(0.0, 32.0, 128.0, 64.0) == 68.0
	# assert  0.75.cerp(0.0, 32.0, 128.0, 64.0) == 85.5
	# assert  1.00.cerp(0.0, 32.0, 128.0, 64.0) == 64.0
	# ~~~
	fun cerp(a, a_handle, b_handle, b: Float): Float do
		var p = self
		var i = 1.0 - p
		var r =     i*i*i  * a +
			3.0*i*i*p * a_handle +
			3.0*i*p*p * b_handle +
			    p*p*p * b
		return r
	end
end
lib/core/math.nit:206,1--385,3

core :: abstract_text $ Float
redef class Float
	# Pretty representation of `self`, with decimals as needed from 1 to a maximum of 3
	#
	# ~~~
	# assert 12.34.to_s       == "12.34"
	# assert (-0120.030).to_s == "-120.03"
	# assert (-inf).to_s == "-inf"
	# assert (nan).to_s == "nan"
	# ~~~
	#
	# see `to_precision` for a custom precision.
	redef fun to_s do
		var str = to_precision(3)
		return adapt_number_of_decimal(str, false)
	end

	# Return the representation of `self`, with scientific notation
	#
	# Adpat the number of decimals as needed from 1 to a maximum of 6
	# ~~~
	# assert 12.34.to_sci       == "1.234e+01"
	# assert 123.45.to_sci.to_f.to_sci  == "1.2345e+02"
	# assert 0.001234.to_sci  == "1.234e-03"
	# assert (inf).to_sci == "inf"
	# assert (nan).to_sci == "nan"
	# ~~~
	fun to_sci: String
	do
		var is_inf_or_nan = check_inf_or_nan
		if is_inf_or_nan != null then return is_inf_or_nan
		return adapt_number_of_decimal(return_from_specific_format("%e".to_cstring), true)
	end

	# Return the `string_number` with the adapted number of decimal (i.e the fonction remove the useless `0`)
	# `is_expo` it's here to specifi if the given `string_number` is in scientific notation
	private fun adapt_number_of_decimal(string_number: String, is_expo: Bool): String
	do
		# check if `self` does not need an adaptation of the decimal
		if is_inf != 0 or is_nan then return string_number
		var len = string_number.length
		var expo_value = ""
		var numeric_value = ""
		for i in [0..len-1] do
			var j = len - 1 - i
			var c = string_number.chars[j]
			if not is_expo then
				if c == '0' then
					continue
				else if c == '.' then
					numeric_value = string_number.substring( 0, j + 2)
					break
				else
					numeric_value = string_number.substring( 0, j + 1)
					break
				end
			else if c == 'e' then
				expo_value = string_number.substring( j, len - 1 )
				is_expo = false
			end
		end
		return numeric_value + expo_value
	end

	# Return a string representation of `self` in fonction if it is not a number or infinity.
	# Return `null` if `self` is not a not a number or an infinity
	private fun check_inf_or_nan: nullable String
	do
		if is_nan then return "nan"

		var isinf = self.is_inf
		if isinf == 1 then
			return "inf"
		else if isinf == -1 then
			return  "-inf"
		end
		return null
	end

	# `String` representation of `self` with the given number of `decimals`
	#
	# ~~~
	# assert 12.345.to_precision(0)    == "12"
	# assert 12.345.to_precision(3)    == "12.345"
	# assert (-12.345).to_precision(3) == "-12.345"
	# assert (-0.123).to_precision(3)  == "-0.123"
	# assert 0.999.to_precision(2)     == "1.00"
	# assert 0.999.to_precision(4)     == "0.9990"
	# ~~~
	fun to_precision(decimals: Int): String
	do
		var is_inf_or_nan = check_inf_or_nan
		if is_inf_or_nan != null then return is_inf_or_nan
		return return_from_specific_format("%.{decimals}f".to_cstring)
	end

	# Returns the hexadecimal (`String`) representation of `self` in exponential notation
	#
	# ~~~
	# assert 12.345.to_hexa_exponential_notation    == "0x1.8b0a3d70a3d71p+3"
	# assert 12.345.to_hexa_exponential_notation.to_f == 12.345
	# ~~~
	fun to_hexa_exponential_notation: String
	do
		return return_from_specific_format("%a".to_cstring)
	end

	# Return the representation of `self`, with the specific given c `format`.
	private fun return_from_specific_format(format: CString): String
	do
		var size = to_precision_size_with_format(format)
		var cstr = new CString(size + 1)
		to_precision_fill_with_format(format, size + 1, cstr)
		return cstr.to_s_unsafe(byte_length = size, copy = false)
	end

	# The lenght of `self` in the specific given c `format`
	private fun to_precision_size_with_format(format: CString): Int`{
		return snprintf(NULL, 0, format, self);
	`}

	# Fill `cstr` with `self` in the specific given c `format`
	private fun to_precision_fill_with_format(format: CString, size: Int, cstr: CString) `{
		snprintf(cstr, size, format, self);
	`}
end
lib/core/text/abstract_text.nit:2026,1--2150,3

core :: time $ Float
redef class Float
	# Sleep approximately `self` seconds
	#
	# Is not interrupted by signals.
	fun sleep `{
		time_t s = self;
		long ns = (self-s) * 1000000000.0;
		struct timespec req = {s, ns};

		while (nanosleep(&req, &req)) { }
	`}
end
lib/core/time.nit:61,1--72,3

core :: numeric $ Float
redef universal Float
	redef fun add(other) do return self + other.to_f
	redef fun sub(other) do return self - other.to_f
	redef fun div(other) do return self / other.to_f
	redef fun mul(other) do return self * other.to_f
end
lib/core/numeric.nit:124,1--129,3

binary :: binary $ Float
redef class Float
	# Utility for `BinaryWriter`
	private fun float_byte_at(index: Int, big_endian: Bool): Int `{
		union {
			unsigned char bytes[4];
			float val;
			uint32_t conv;
		} u;

		u.val = self;

		if (big_endian)
			u.conv = htobe32(u.conv);
		else u.conv = htole32(u.conv);

		return u.bytes[index];
	`}

	# Utility for `BinaryWriter`
	private fun double_byte_at(index: Int, big_endian: Bool): Int `{
		union {
			unsigned char bytes[8];
			double val;
			uint64_t conv;
		} u;

		u.val = self;

		if (big_endian)
			u.conv = htobe64(u.conv);
		else u.conv = htole64(u.conv);

		return u.bytes[index];
	`}
end
lib/binary/binary.nit:361,1--395,3

jvm :: jvm $ Float
redef class Float
	redef fun to_jvalue(env): JValue `{
		jvalue value;
		value.f = self;
		return value;
	`}
end
lib/jvm/jvm.nit:517,1--523,3

gmp :: gmp $ Float
redef class Float
    redef fun to_bi do
        var tmp = new NativeMPZ
        tmp.set_d self
        return new BigInt(tmp)
    end

    redef fun to_r do
        var tmp = new NativeMPQ
        tmp.set_d self
        return new Ratio(tmp)
    end
end
lib/gmp/gmp.nit:92,1--104,3

sqlite3 :: sqlite3 $ Float
redef universal Float super Sqlite3Data end
lib/sqlite3/sqlite3.nit:319,1--43

serialization :: serialization_core $ Float
redef class Float super DirectSerializable end
lib/serialization/serialization_core.nit:262,1--46

json :: serialization_write $ Float
redef class Float
	redef fun accept_json_serializer(v) do v.stream.write to_s
end
lib/json/serialization_write.nit:268,1--270,3

serialization :: inspect $ Float
redef class Float
	redef fun accept_inspect_serializer(v) do v.stream.write to_s
end
lib/serialization/inspect.nit:195,1--197,3

noise :: noise $ Float
redef universal Float
	# Smoothened `self`, used by `ImprovedNoise`
	private fun fade: Float do return self*self*self*(self*(self*6.0-15.0)+10.0)
end
lib/noise/noise.nit:363,1--366,3

geometry :: angles $ Float
redef universal Float
	# Normalize the `self` angle in radians to be within `[-pi .. pi[`
	#
	# ~~~
	# assert (1.5*pi).angle_normalize.is_approx(-0.5*pi, 0.0001)
	# assert 8.0.angle_normalize.is_approx(1.7168, 0.0001)
	# assert (-1.0).angle_normalize == -1.0
	# ~~~
	fun angle_normalize: Float
	do
		var s = self
		while s < -pi do s += 2.0*pi
		while s >= pi do s -= 2.0*pi
		return s
	end

	# Linear interpolation of between the angles `a` and `b`, in radians
	#
	# The result is normalized with `angle_normalize`.
	#
	# ~~~
	# assert 0.5.angle_lerp(0.0, pi).is_approx(0.5*pi, 0.0001)
	# assert 8.5.angle_lerp(0.0, pi).is_approx(0.5*pi, 0.0001)
	# assert 7.5.angle_lerp(0.0, pi).is_approx(-0.5*pi, 0.0001)
	# assert 0.5.angle_lerp(0.2, 2.0*pi-0.1).is_approx(0.05, 0.0001)
	# ~~~
	fun angle_lerp(a, b: Float): Float
	do
		var d = b - a
		while d > pi do d -= 2.0*pi
		while d < -pi do d += 2.0*pi
		return (a + d*self).angle_normalize
	end
end
lib/geometry/angles.nit:38,1--71,3

msgpack :: serialization_write $ Float
redef class Float
	redef fun accept_msgpack_serializer(v) do v.stream.write_msgpack_double self
end
lib/msgpack/serialization_write.nit:252,1--254,3

android :: bundle $ Float
redef class Float
	redef fun add_to_bundle(bundle, key)
	do
		bundle.put_double(key, self)
	end
end
lib/android/bundle/bundle.nit:700,1--705,3