1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 03:22:48 -05:00

Add functions mp_max and mp_max_into.

These are easy, and just like the existing mp_min family; I just
hadn't needed them before now.
This commit is contained in:
Simon Tatham
2019-01-29 20:02:39 +00:00
parent 715356e6d2
commit d4ad7272fd
4 changed files with 27 additions and 5 deletions

12
mpint.c
View File

@ -2109,6 +2109,11 @@ void mp_min_into(mp_int *r, mp_int *x, mp_int *y)
mp_select_into(r, x, y, mp_cmp_hs(x, y));
}
void mp_max_into(mp_int *r, mp_int *x, mp_int *y)
{
mp_select_into(r, y, x, mp_cmp_hs(x, y));
}
mp_int *mp_min(mp_int *x, mp_int *y)
{
mp_int *r = mp_make_sized(size_t_min(x->nw, y->nw));
@ -2116,6 +2121,13 @@ mp_int *mp_min(mp_int *x, mp_int *y)
return r;
}
mp_int *mp_max(mp_int *x, mp_int *y)
{
mp_int *r = mp_make_sized(size_t_max(x->nw, y->nw));
mp_max_into(r, x, y);
return r;
}
mp_int *mp_power_2(size_t power)
{
mp_int *x = mp_new(power + 1);