From a7e6303e3e7e87bf90b21821d2e419ed4799783c Mon Sep 17 00:00:00 2001 From: musil Date: Fri, 28 Jun 2013 17:25:22 +0000 Subject: initial check in of double precision library of iem svn path=/trunk/externals/iem/iem_dp/; revision=17167 --- src/ftohex.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 src/ftohex.c (limited to 'src/ftohex.c') diff --git a/src/ftohex.c b/src/ftohex.c new file mode 100755 index 0000000..62cde68 --- /dev/null +++ b/src/ftohex.c @@ -0,0 +1,49 @@ +/* For information on usage and redistribution, and for a DISCLAIMER OF ALL +* WARRANTIES, see the file, "LICENSE.txt," in this distribution. + +iem_dp written by IOhannes m zmoelnig, Thomas Musil, Copyright (c) IEM KUG Graz Austria 1999 - 2007 */ +/* double precision library */ + +#include "m_pd.h" +#include "iemlib.h" +#include "iem_dp.h" +#include +#include +#include + +/* -------------------------- ftohex ------------------------------ */ +/* float to 8 digits of hexadecimal converter */ + +/* float (sign_1 + exp_8 + mant_23) */ + + +static t_class *ftohex_class; + +typedef struct _ftohex +{ + t_object x_obj; +} t_ftohex; + +static void ftohex_float(t_ftohex *x, t_floatarg f) +{ + char buf[100]; + union tabfudge_f tf; + + tf.tf_f = f; + sprintf(buf, "#%08X", (unsigned int)tf.tf_l); + outlet_symbol(x->x_obj.ob_outlet, gensym(buf)); +} + +static void *ftohex_new(void) +{ + t_ftohex *x = (t_ftohex *)pd_new(ftohex_class); + outlet_new(&x->x_obj, &s_symbol); + return (x); +} + +void ftohex_setup(void) +{ + ftohex_class = class_new(gensym("ftohex"), + (t_newmethod)ftohex_new, 0, sizeof(t_ftohex), 0, 0); + class_addfloat(ftohex_class, ftohex_float); +} -- cgit v1.2.1