Add sr_rational_set() convenience function.
This commit is contained in:
parent
cd3c4df35a
commit
90cefe0cc7
|
@ -33,6 +33,7 @@ SR_API int sr_analog_to_float(const struct sr_datafeed_analog2 *analog,
|
|||
SR_API int sr_analog_float_to_string(float value, int digits, char **result);
|
||||
SR_API int sr_analog_unit_to_string(const struct sr_datafeed_analog2 *analog,
|
||||
char **result);
|
||||
SR_API inline void sr_rational_set(struct sr_rational *r, uint64_t p, uint64_t q);
|
||||
|
||||
/*--- backend.c -------------------------------------------------------------*/
|
||||
|
||||
|
|
12
src/analog.c
12
src/analog.c
|
@ -229,3 +229,15 @@ SR_API int sr_analog_unit_to_string(const struct sr_datafeed_analog2 *analog,
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set sr_rational r to the given value.
|
||||
*
|
||||
* @param p Numerator
|
||||
* @param q Denominator
|
||||
*/
|
||||
SR_API inline void sr_rational_set(struct sr_rational *r, uint64_t p, uint64_t q)
|
||||
{
|
||||
r->p = p;
|
||||
r->q = q;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue