Prusa MINI Firmware overview
int_to_cstr.h File Reference
#include "stdint.h"
#include "stdlib.h"

Go to the source code of this file.

Functions

constexpr bool is_negative (int32_t i)
 
constexpr size_t count_digits (int32_t i)
 
constexpr char nth_char (int32_t i, size_t n)
 
constexpr int pow_int (int val, size_t pow)
 
constexpr int remove_front_digit (int32_t i)
 
static constexpr size_t _count_digits_unsigned (uint32_t ui)
 
static constexpr size_t count_digits_unsigned (uint32_t ui)
 
static constexpr char valid_nth_char_unsigned (uint32_t ui, size_t n)
 
static constexpr char nth_char_unsigned (uint32_t ui, size_t n)
 
static constexpr char nth_char_negative (int32_t i, size_t n)
 
static constexpr int remove_front_digit_unsigned (uint32_t ui)
 

Function Documentation

◆ is_negative()

constexpr bool is_negative ( int32_t  i)
constexpr
26  {
27  return i < 0;
28 }
Here is the caller graph for this function:

◆ count_digits()

constexpr size_t count_digits ( int32_t  i)
constexpr
30  {
32 }
Here is the call graph for this function:

◆ nth_char()

constexpr char nth_char ( int32_t  i,
size_t  n 
)
constexpr
49  {
50  return i < 0 ? nth_char_negative(i, n) : nth_char_unsigned(i, n);
51 }
Here is the call graph for this function:

◆ pow_int()

constexpr int pow_int ( int  val,
size_t  pow 
)
constexpr
53  {
54  return pow == 0 ? 1 : val * pow_int(val, pow - 1);
55 }
Here is the caller graph for this function:

◆ remove_front_digit()

constexpr int remove_front_digit ( int32_t  i)
constexpr
61  {
62  return i < 0 ? -1 : remove_front_digit_unsigned(i);
63 }
Here is the call graph for this function:

◆ _count_digits_unsigned()

static constexpr size_t _count_digits_unsigned ( uint32_t  ui)
staticconstexpr
17  {
18  return ui > 0 ? _count_digits_unsigned(ui / 10) + 1 : 0;
19 }
Here is the caller graph for this function:

◆ count_digits_unsigned()

static constexpr size_t count_digits_unsigned ( uint32_t  ui)
staticconstexpr
22  {
23  return ui == 0 ? 1 : _count_digits_unsigned(ui);
24 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ valid_nth_char_unsigned()

static constexpr char valid_nth_char_unsigned ( uint32_t  ui,
size_t  n 
)
staticconstexpr
35  {
36  return n == count_digits_unsigned(ui) - 1 ? (ui % 10) + '0' : valid_nth_char_unsigned(ui / 10, n);
37 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nth_char_unsigned()

static constexpr char nth_char_unsigned ( uint32_t  ui,
size_t  n 
)
staticconstexpr
40  {
41  return n >= count_digits_unsigned(ui) ? 0 : valid_nth_char_unsigned(ui, n);
42 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nth_char_negative()

static constexpr char nth_char_negative ( int32_t  i,
size_t  n 
)
staticconstexpr
45  {
46  return n == 0 ? '-' : nth_char_unsigned(-i, n - 1);
47 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_front_digit_unsigned()

static constexpr int remove_front_digit_unsigned ( uint32_t  ui)
staticconstexpr
57  {
58  return ui % pow_int(10, count_digits_unsigned(ui));
59 }
Here is the call graph for this function:
Here is the caller graph for this function:
i
uint8_t i
Definition: screen_test_graph.c:72
nth_char_unsigned
static constexpr char nth_char_unsigned(uint32_t ui, size_t n)
Definition: int_to_cstr.h:40
count_digits_unsigned
static constexpr size_t count_digits_unsigned(uint32_t ui)
Definition: int_to_cstr.h:22
pow_int
constexpr int pow_int(int val, size_t pow)
Definition: int_to_cstr.h:53
_count_digits_unsigned
static constexpr size_t _count_digits_unsigned(uint32_t ui)
Definition: int_to_cstr.h:17
is_negative
constexpr bool is_negative(int32_t i)
Definition: int_to_cstr.h:26
remove_front_digit_unsigned
static constexpr int remove_front_digit_unsigned(uint32_t ui)
Definition: int_to_cstr.h:57
ui
MarlinUI ui
nth_char_negative
static constexpr char nth_char_negative(int32_t i, size_t n)
Definition: int_to_cstr.h:45
valid_nth_char_unsigned
static constexpr char valid_nth_char_unsigned(uint32_t ui, size_t n)
Definition: int_to_cstr.h:35