Skip to content

Commit

Permalink
rename example
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Dec 16, 2024
1 parent 57aabe1 commit e83f074
Show file tree
Hide file tree
Showing 8 changed files with 421 additions and 288 deletions.
2 changes: 1 addition & 1 deletion examples/xtd.core.examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
* [format_enum_class](format/format_enum_class/README.md) shows how to use [xtd::format](https://gammasoft71.github.io/xtd/reference_guides/latest/_format_page.html) method with owner enum class.
* [format_exception](format/format_exception/README.md) shows how to use [xtd::format](https://gammasoft71.github.io/xtd/reference_guides/latest/_format_page.html) method with exceptions (std::exception and inherited classes, xtd::system_exception and inherited classes).
* [format_floating_point](format/format_floating_point/README.md) shows how to use [xtd::format](https://gammasoft71.github.io/xtd/reference_guides/latest/_format_page.html) method with floating point (float, double and long double).
* [format_numeric](format/format_numeric/README.md) shows how to use [xtd::format](https://gammasoft71.github.io/xtd/reference_guides/latest/_format_page.html) method with numeric (int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t and uint64_t).
* [format_number](format/format_number/README.md) shows how to use [xtd::format](https://gammasoft71.github.io/xtd/reference_guides/latest/_format_page.html) method with numeric (int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t and uint64_t).
* [format_nullptr](format/format_nullptr/README.md) shows how to use [xtd::format](https://gammasoft71.github.io/xtd/reference_guides/latest/_format_page.html) method with nulllptr and null.
* [format_optional](format/format_optional/README.md) shows how to use [xtd::format](https://gammasoft71.github.io/xtd/reference_guides/latest/_format_page.html) method with std::format_optional.
* [format_pair](format/format_pair/README.md) shows how to use [xtd::format](https://gammasoft71.github.io/xtd/reference_guides/latest/_format_page.html) method with std::pair.
Expand Down
2 changes: 1 addition & 1 deletion examples/xtd.core.examples/format/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ add_projects(
format_enum_class_flags_without_helper
format_exception
format_floating_point
format_numeric
format_number
format_nullptr
format_optional
format_pair
Expand Down
2 changes: 1 addition & 1 deletion examples/xtd.core.examples/format/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* [format_enum_class](format_enum_class/README.md) shows how to use [xtd::format](https://codedocs.xyz/gammasoft71/xtd/_format_page.html) method with owner enum class.
* [format_exception](format_exception/README.md) shows how to use [xtd::format](https://codedocs.xyz/gammasoft71/xtd/_format_page.html) method with exceptions (std::exception and inherited classes, xtd::system_exception and inherited classes).
* [format_floating_point](format_floating_point/README.md) shows how to use [xtd::format](https://codedocs.xyz/gammasoft71/xtd/_format_page.html) method with floating point (float, double and long double).
* [format_numeric](format_numeric/README.md) shows how to use [xtd::format](https://codedocs.xyz/gammasoft71/xtd/_format_page.html) method with numeric (int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t and uint64_t).
* [format_number](format_number/README.md) shows how to use [xtd::format](https://codedocs.xyz/gammasoft71/xtd/_format_page.html) method with numeric (int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t and uint64_t).
* [format_nullptr](format_nullptr/README.md) shows how to use [xtd::format](https://codedocs.xyz/gammasoft71/xtd/_format_page.html) method with nullptr and null.
* [format_optional](format_optional/README.md) shows how to use [xtd::format](https://codedocs.xyz/gammasoft71/xtd/_format_page.html) method with std::format_optional.
* [format_pair](format_pair/README.md) shows how to use [xtd::format](https://codedocs.xyz/gammasoft71/xtd/_format_page.html) method with std::pair.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.20)

project(format_numeric)
project(format_number)
find_package(xtd REQUIRED)
add_sources(README.md src/format_numeric.cpp)
add_sources(README.md src/format_number.cpp)
target_type(CONSOLE_APPLICATION)
186 changes: 186 additions & 0 deletions examples/xtd.core.examples/format/format_number/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# format_number

Show how to use format [xtd::format](https://gammasoft71.github.io/xtd/reference_guides/latest/_format_page.html) class with numeric values.

## Sources

[src/format_number.cpp](src/format_number.cpp)

[CMakeLists.txt](CMakeLists.txt)

## Build and run

Open "Command Prompt" or "Terminal". Navigate to the folder that contains the project and type the following:

```cmake
xtdc run
```

# Output (with colors)

```
┌───────────────────────────┬────────────┬──────────────────────────────────┐
│ number │ format │ representation │
├───────────────────────────┼────────────┼──────────────────────────────────┤
│ 0 │ {} │ 0 │
│ 0 │ {:b} │ 0 │
│ 0 │ {:b32} │ 00000000000000000000000000000000 │
│ 0 │ {:B} │ 0 │
│ 0 │ {:B32} │ 00000000000000000000000000000000 │
│ 0 │ {:c} │ $0.00 │
│ 0 │ {:C} │ $0.00 │
│ 0 │ {:d} │ 0 │
│ 0 │ {:d16} │ 0000000000000000 │
│ 0 │ {:D} │ 0 │
│ 0 │ {:D16} │ 0000000000000000 │
│ 0 │ {:e} │ 0.000000e+00 │
│ 0 │ {:E} │ 0.000000E+00 │
│ 0 │ {:f} │ 0.00 │
│ 0 │ {:f4} │ 0.0000 │
│ 0 │ {:F} │ 0.00 │
│ 0 │ {:F4} │ 0.0000 │
│ 0 │ {:g} │ 0 │
│ 0 │ {:G} │ 0 │
│ 0 │ {:o} │ 0 │
│ 0 │ {:o16} │ 0000000000000000 │
│ 0 │ {:O} │ 0 │
│ 0 │ {:O16} │ 0000000000000000 │
│ 0 │ {:n} │ 0.00 │
│ 0 │ {:N} │ 0.00 │
│ 0 │ {:p} │ 0.00 % │
│ 0 │ {:P} │ 0.00 % │
│ 0 │ {:x} │ 0 │
│ 0 │ {:x16} │ 0000000000000000 │
│ 0 │ {:X} │ 0 │
│ 0 │ {:X16} │ 0000000000000000 │
├───────────────────────────┼────────────┼──────────────────────────────────┤
│ 42_s8 │ {} │ 42 │
│ 42_s8 │ {:b} │ 101010 │
│ 42_s8 │ {:b32} │ 00000000000000000000000000101010 │
│ 42_s8 │ {:B} │ 101010 │
│ 42_s8 │ {:B32} │ 00000000000000000000000000101010 │
│ 42_s8 │ {:c} │ $42.00 │
│ 42_s8 │ {:C} │ $42.00 │
│ 42_s8 │ {:d} │ 42 │
│ 42_s8 │ {:d16} │ 0000000000000042 │
│ 42_s8 │ {:D} │ 42 │
│ 42_s8 │ {:D16} │ 0000000000000042 │
│ 42_s8 │ {:e} │ 4.200000e+01 │
│ 42_s8 │ {:E} │ 4.200000E+01 │
│ 42_s8 │ {:f} │ 42.00 │
│ 42_s8 │ {:f4} │ 42.0000 │
│ 42_s8 │ {:F} │ 42.00 │
│ 42_s8 │ {:F4} │ 42.0000 │
│ 42_s8 │ {:g} │ 42 │
│ 42_s8 │ {:G} │ 42 │
│ 42_s8 │ {:o} │ 52 │
│ 42_s8 │ {:o16} │ 0000000000000052 │
│ 42_s8 │ {:O} │ 52 │
│ 42_s8 │ {:O16} │ 0000000000000052 │
│ 42_s8 │ {:n} │ 42.00 │
│ 42_s8 │ {:N} │ 42.00 │
│ 42_s8 │ {:p} │ 4200.00 % │
│ 42_s8 │ {:P} │ 4200.00 % │
│ 42_s8 │ {:x} │ 2a │
│ 42_s8 │ {:x16} │ 000000000000002a │
│ 42_s8 │ {:X} │ 2A │
│ 42_s8 │ {:X16} │ 000000000000002A │
├───────────────────────────┼────────────┼──────────────────────────────────┤
│ 123456789ull │ {} │ 123456789 │
│ 123456789ull │ {:b} │ 111010110111100110100010101 │
│ 123456789ull │ {:b32} │ 00000111010110111100110100010101 │
│ 123456789ull │ {:B} │ 111010110111100110100010101 │
│ 123456789ull │ {:B32} │ 00000111010110111100110100010101 │
│ 123456789ull │ {:c} │ $123,456,789.00 │
│ 123456789ull │ {:C} │ $123,456,789.00 │
│ 123456789ull │ {:d} │ 123456789 │
│ 123456789ull │ {:d16} │ 0000000123456789 │
│ 123456789ull │ {:D} │ 123456789 │
│ 123456789ull │ {:D16} │ 0000000123456789 │
│ 123456789ull │ {:e} │ 1.234568e+08 │
│ 123456789ull │ {:E} │ 1.234568E+08 │
│ 123456789ull │ {:f} │ 123456789.00 │
│ 123456789ull │ {:f4} │ 123456789.0000 │
│ 123456789ull │ {:F} │ 123456789.00 │
│ 123456789ull │ {:F4} │ 123456789.0000 │
│ 123456789ull │ {:g} │ 123456789 │
│ 123456789ull │ {:G} │ 123456789 │
│ 123456789ull │ {:o} │ 726746425 │
│ 123456789ull │ {:o16} │ 0000000726746425 │
│ 123456789ull │ {:O} │ 726746425 │
│ 123456789ull │ {:O16} │ 0000000726746425 │
│ 123456789ull │ {:n} │ 123,456,789.00 │
│ 123456789ull │ {:N} │ 123,456,789.00 │
│ 123456789ull │ {:p} │ 12345678900.00 % │
│ 123456789ull │ {:P} │ 12345678900.00 % │
│ 123456789ull │ {:x} │ 75bcd15 │
│ 123456789ull │ {:x16} │ 00000000075bcd15 │
│ 123456789ull │ {:X} │ 75BCD15 │
│ 123456789ull │ {:X16} │ 00000000075BCD15 │
├───────────────────────────┼────────────┼──────────────────────────────────┤
│ int16_object::min_value │ {} │ -32768 │
│ int16_object::min_value │ {:b} │ 1000000000000000 │
│ int16_object::min_value │ {:b32} │ 00000000000000001000000000000000 │
│ int16_object::min_value │ {:B} │ 1000000000000000 │
│ int16_object::min_value │ {:B32} │ 00000000000000001000000000000000 │
│ int16_object::min_value │ {:c} │ -$32,768.00 │
│ int16_object::min_value │ {:C} │ -$32,768.00 │
│ int16_object::min_value │ {:d} │ -32768 │
│ int16_object::min_value │ {:d16} │ -0000000000032768 │
│ int16_object::min_value │ {:D} │ -32768 │
│ int16_object::min_value │ {:D16} │ -0000000000032768 │
│ int16_object::min_value │ {:e} │ -3.276800e+04 │
│ int16_object::min_value │ {:E} │ -3.276800E+04 │
│ int16_object::min_value │ {:f} │ -32768.00 │
│ int16_object::min_value │ {:f4} │ -32768.0000 │
│ int16_object::min_value │ {:F} │ -32768.00 │
│ int16_object::min_value │ {:F4} │ -32768.0000 │
│ int16_object::min_value │ {:g} │ -32768 │
│ int16_object::min_value │ {:G} │ -32768 │
│ int16_object::min_value │ {:o} │ 1777777777777777700000 │
│ int16_object::min_value │ {:o16} │ 1777777777777777700000 │
│ int16_object::min_value │ {:O} │ 1777777777777777700000 │
│ int16_object::min_value │ {:O16} │ 1777777777777777700000 │
│ int16_object::min_value │ {:n} │ -32,768.00 │
│ int16_object::min_value │ {:N} │ -32,768.00 │
│ int16_object::min_value │ {:p} │ -3276800.00 % │
│ int16_object::min_value │ {:P} │ -3276800.00 % │
│ int16_object::min_value │ {:x} │ ffffffffffff8000 │
│ int16_object::min_value │ {:x16} │ ffffffffffff8000 │
│ int16_object::min_value │ {:X} │ FFFFFFFFFFFF8000 │
│ int16_object::min_value │ {:X16} │ FFFFFFFFFFFF8000 │
├───────────────────────────┼────────────┼──────────────────────────────────┤
│ int32_object::max_value │ {} │ 2147483647 │
│ int32_object::max_value │ {:b} │ 1111111111111111111111111111111 │
│ int32_object::max_value │ {:b32} │ 01111111111111111111111111111111 │
│ int32_object::max_value │ {:B} │ 1111111111111111111111111111111 │
│ int32_object::max_value │ {:B32} │ 01111111111111111111111111111111 │
│ int32_object::max_value │ {:c} │ $2,147,483,647.00 │
│ int32_object::max_value │ {:C} │ $2,147,483,647.00 │
│ int32_object::max_value │ {:d} │ 2147483647 │
│ int32_object::max_value │ {:d16} │ 0000002147483647 │
│ int32_object::max_value │ {:D} │ 2147483647 │
│ int32_object::max_value │ {:D16} │ 0000002147483647 │
│ int32_object::max_value │ {:e} │ 2.147484e+09 │
│ int32_object::max_value │ {:E} │ 2.147484E+09 │
│ int32_object::max_value │ {:f} │ 2147483647.00 │
│ int32_object::max_value │ {:f4} │ 2147483647.0000 │
│ int32_object::max_value │ {:F} │ 2147483647.00 │
│ int32_object::max_value │ {:F4} │ 2147483647.0000 │
│ int32_object::max_value │ {:g} │ 2147483647 │
│ int32_object::max_value │ {:G} │ 2147483647 │
│ int32_object::max_value │ {:o} │ 17777777777 │
│ int32_object::max_value │ {:o16} │ 0000017777777777 │
│ int32_object::max_value │ {:O} │ 17777777777 │
│ int32_object::max_value │ {:O16} │ 0000017777777777 │
│ int32_object::max_value │ {:n} │ 2,147,483,647.00 │
│ int32_object::max_value │ {:N} │ 2,147,483,647.00 │
│ int32_object::max_value │ {:p} │ 214748364700.00 % │
│ int32_object::max_value │ {:P} │ 214748364700.00 % │
│ int32_object::max_value │ {:x} │ 7fffffff │
│ int32_object::max_value │ {:x16} │ 000000007fffffff │
│ int32_object::max_value │ {:X} │ 7FFFFFFF │
│ int32_object::max_value │ {:X16} │ 000000007FFFFFFF │
└───────────────────────────┴────────────┴──────────────────────────────────┘
```

Loading

0 comments on commit e83f074

Please sign in to comment.