annotate tools/stof.c @ 0:5242703e91d3 tip

Initial checkin for AIM92 aimR8.2 (last updated May 1997).
author tomwalters
date Fri, 20 May 2011 15:19:45 +0100
parents
children
rev   line source
tomwalters@0 1 /*
tomwalters@0 2 stof.c binary short-to-float conversion.
tomwalters@0 3 --------
tomwalters@0 4
tomwalters@0 5 */
tomwalters@0 6
tomwalters@0 7 #include <stdio.h>
tomwalters@0 8 #include <math.h>
tomwalters@0 9 #include "options.h"
tomwalters@0 10
tomwalters@0 11 char applic[] = "short to float data-type conversion." ;
tomwalters@0 12
tomwalters@0 13 static char *helpstr ;
tomwalters@0 14
tomwalters@0 15 static Options option[] = {
tomwalters@0 16 { "help" , "off" , &helpstr , "help" , DEBUG },
tomwalters@0 17 ( char * ) 0 } ;
tomwalters@0 18
tomwalters@0 19
tomwalters@0 20 main(argc, argv)
tomwalters@0 21 int argc ;
tomwalters@0 22 char *argv[] ;
tomwalters@0 23 {
tomwalters@0 24 FILE *fp ;
tomwalters@0 25 short X;
tomwalters@0 26 float Y;
tomwalters@0 27
tomwalters@0 28 fp = openopts( option,argc,argv ) ;
tomwalters@0 29 if ( !isoff( helpstr ) )
tomwalters@0 30 helpopts( helpstr, argv[0], applic, option ) ;
tomwalters@0 31
tomwalters@0 32 while ( fread( &X, sizeof(short), 1, fp ) ) {
tomwalters@0 33 Y = (float)X ;
tomwalters@0 34 fwrite( &Y, sizeof(float), 1, stdout);
tomwalters@0 35 }
tomwalters@0 36
tomwalters@0 37 fclose(fp);
tomwalters@0 38 exit(0);
tomwalters@0 39 }
tomwalters@0 40
tomwalters@0 41