# ms_genfactmult - Man Page

Generate SEED sample rate factor and multiplier

## Synopsis

#include <libmseed.h> int ms_genfactmult ( doublesamprate, int16_t *factor, int16_t *multiplier); int ms_ratapprox ( doublereal, int *num, int *den, intmaxval, doubleprecision);

## Description

**ms_genfactmult** generates an appropriate SEED sample rate *factor* and *multiplier* pair from a double precision sample rate. If *samprate* is positive it is expected to represent a rate in samples/second, if negative is is expected to represent a period in seconds/sample.

Non-integer sample rates and periods are supported between 32767.0 and 1/32767.0. An error will be returned for non-integer rates and periods outside this range.

Integer sample rates and periods are supported between 1 and the maximum possible value (32767 * 32767). Values from 1 to 32767 are represented directly. Values larger than 32767 are factored and represented exactly when possible and approximated otherwise, with the discrepency becoming larger as the values reach the maximum possible value.

The factor and multiplier are int16_t because that is the integer size needed for the fixed section of the SEED data header.

**ms_ratapprox** finds an approximate rational number for a real through continued fraction expansion. Given a double precision *real* the routine tries to find a rational in numerator (*num*) and denominator (*den*) form whose absolute values are not larger than *maxval* while trying to reach a specified *precision*.

## Return Values

**ms_genfactmult** returns 0 on success and -1 when value is outside of the supported range or error.

**ms_ratapprox** returns the number of iterations performed.

## Author

Chad Trabant IRIS Data Management Center

## Referenced By

The man page ms_ratapprox(3) is an alias of ms_genfactmult(3).