Mercurial > hg > fxanalyse
view utils.c @ 268:ec4462c7f8b7
Extensive cleanup of beatnote specific variables
Reorganize the beatnote specific variables in arrays indexed by the
beatnote enum constants LO, HG, SR. Also reorganize DDS frequency
related variables in arrays indexed by the DDS channel number.
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Thu, 09 Jul 2015 23:11:00 +0200 |
parents | be87c8e78266 |
children |
line wrap: on
line source
#include <ansi_c.h> const char * thousands(char *buffer, int size, char *fmt, double val) { /* compute how many separators we need */ #pragma DisableFunctionRuntimeChecking log10 int nsep = log10(fabs(val)); nsep = (nsep > 0 ? nsep / 3 : 0); /* format value */ int len = snprintf(buffer, size, fmt, val); char *src = buffer + len; char *dst = src + nsep; /* copy till decimal separator */ while (*src != '.') *dst-- = *src--; /* the next char is the decimal separator */ int n = -1; /* copy till src and dst point to the same location */ while (src != dst) { *dst-- = *src--; /* insert separator */ if (isdigit(*src) && (++n) && ((n % 3) == 0)) *dst-- = ' '; } return buffer; } double Peta(double x) { return 1.0e15 * x; } double Tera(double x) { return 1.0e12 * x; } double Giga(double x) { return 1.0e9 * x; } double Mega(double x) { return 1.0e6 * x; } double kilo(double x) { return 1.0e3 * x; } double milli(double x) { return 1.0e-3 * x; } double micro(double x) { return 1.0e-6 * x; } double nano(double x) { return 1.0e-9 * x; } double pico(double x) { return 1.e-12 * x; } double femto(double x) { return 1.0e-15 * x; }