mirror of
https://github.com/enso-org/enso.git
synced 2024-12-28 11:25:30 +03:00
Integer.to_decimal
and Float.to_decimal
(#9716)
This commit is contained in:
parent
58009b7c04
commit
bc61d686c1
@ -650,6 +650,7 @@
|
||||
- [Added `Decimal.min` and `.max`.][9663]
|
||||
- [Added `Decimal.round`.][9672]
|
||||
- [Implemented write support for Enso Cloud files.][9686]
|
||||
- [Added `Integer.to_decimal` and `Float.to_decimal`.][9716]
|
||||
- [Added `Decimal.floor`, `.ceil`, and `.trunc`.][9694]
|
||||
- [Added `recursive` option to `File.delete`.][9719]
|
||||
- [Added `Vector.build`.][9725]
|
||||
@ -954,6 +955,7 @@
|
||||
[9672]: https://github.com/enso-org/enso/pull/9672
|
||||
[9686]: https://github.com/enso-org/enso/pull/9686
|
||||
[9694]: https://github.com/enso-org/enso/pull/9694
|
||||
[9716]: https://github.com/enso-org/enso/pull/9716
|
||||
[9719]: https://github.com/enso-org/enso/pull/9719
|
||||
[9725]: https://github.com/enso-org/enso/pull/9725
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import project.Any.Any
|
||||
import project.Data.Decimal.Decimal
|
||||
import project.Data.Locale.Locale
|
||||
import project.Data.Ordering.Comparable
|
||||
import project.Data.Text.Text
|
||||
@ -731,6 +732,17 @@ type Float
|
||||
5.0.to_float
|
||||
to_float self -> Float = self
|
||||
|
||||
## ICON convert
|
||||
Convert this to a `Decimal`.
|
||||
|
||||
> Example
|
||||
Convert 12.3 to a Decimal.
|
||||
|
||||
12.3 . to_decimal
|
||||
# => Decimal.new "12.3"
|
||||
to_decimal : Decimal
|
||||
to_decimal self -> Decimal = Decimal.from_float self
|
||||
|
||||
## ALIAS from text
|
||||
GROUP Conversions
|
||||
ICON convert
|
||||
@ -1080,6 +1092,17 @@ type Integer
|
||||
5.to_float
|
||||
to_float self -> Float = integer_to_float self
|
||||
|
||||
## ICON convert
|
||||
Convert this to a `Decimal`.
|
||||
|
||||
> Example
|
||||
Convert 12 to a Decimal.
|
||||
|
||||
12 . to_decimal
|
||||
# => Decimal.new "12"
|
||||
to_decimal : Decimal
|
||||
to_decimal self -> Decimal = Decimal.from_integer self
|
||||
|
||||
## GROUP Bitwise
|
||||
ICON math
|
||||
Computes the bitwise and (conjunction) operation between this and
|
||||
|
@ -943,6 +943,18 @@ add_specs suite_builder =
|
||||
Math.min (Decimal.new "12E70") (Decimal.new "13E70") . should_equal (Decimal.new "12E70")
|
||||
Math.max (Decimal.new "12E70") (Decimal.new "13E70") . should_equal (Decimal.new "13E70")
|
||||
|
||||
suite_builder.group "Integer/Float .to_decimal" group_builder->
|
||||
group_builder.specify ".to_decimal should convert to Decimal" <|
|
||||
12 . to_decimal . should_be_a Decimal
|
||||
12.3 . to_decimal . should_be_a Decimal
|
||||
|
||||
group_builder.specify "Float.to_decimal should attach a warning" <|
|
||||
Problems.expect_warning Loss_Of_Numeric_Precision (12.3 . to_decimal)
|
||||
|
||||
group_builder.specify "examples" <|
|
||||
12 . to_decimal . should_equal (Decimal.new "12")
|
||||
12.3 . to_decimal . should_equal (Decimal.new "12.3")
|
||||
|
||||
suite_builder.group "BigDecimal internal representation methods" group_builder->
|
||||
group_builder.specify "internal accessors should work correctly" <|
|
||||
d = Decimal.new "123.456"
|
||||
|
@ -259,10 +259,10 @@ add_specs suite_builder =
|
||||
methods.sort . should_equal ['Value', 'create', 'factory', 'first_method', 'my_method', 'other_method', 'second_method']
|
||||
|
||||
group_builder.specify "methods of Integer" <|
|
||||
Meta.meta Integer . methods . sort . should_equal ['%', '*', '+', '-', '/', '<', '<=', '>', '>=', '^', 'abs', 'bit_and', 'bit_not', 'bit_or', 'bit_shift', 'bit_shift_l', 'bit_shift_r', 'bit_xor', 'ceil', 'div', 'floor', 'negate', 'round', 'to_float', 'truncate']
|
||||
Meta.meta Integer . methods . sort . should_equal ['%', '*', '+', '-', '/', '<', '<=', '>', '>=', '^', 'abs', 'bit_and', 'bit_not', 'bit_or', 'bit_shift', 'bit_shift_l', 'bit_shift_r', 'bit_xor', 'ceil', 'div', 'floor', 'negate', 'round', 'to_decimal', 'to_float', 'truncate']
|
||||
|
||||
group_builder.specify "static methods of Integer" <|
|
||||
Meta.meta (Meta.type_of Integer) . methods . sort . should_equal ['%', '*', '+', '-', '/', '<', '<=', '>', '>=', '^', 'abs', 'bit_and', 'bit_not', 'bit_or', 'bit_shift', 'bit_shift_l', 'bit_shift_r', 'bit_xor', 'ceil', 'div', 'floor', 'negate', 'parse', 'round', 'to_float', 'truncate']
|
||||
Meta.meta (Meta.type_of Integer) . methods . sort . should_equal ['%', '*', '+', '-', '/', '<', '<=', '>', '>=', '^', 'abs', 'bit_and', 'bit_not', 'bit_or', 'bit_shift', 'bit_shift_l', 'bit_shift_r', 'bit_xor', 'ceil', 'div', 'floor', 'negate', 'parse', 'round', 'to_decimal', 'to_float', 'truncate']
|
||||
|
||||
group_builder.specify "methods of Any" <|
|
||||
Meta.meta Any . methods . should_contain "to_text"
|
||||
|
Loading…
Reference in New Issue
Block a user