]> git.mxchange.org Git - simgear.git/blob - simgear/metar/Fracpart.cpp
Fixes for MSVC++.
[simgear.git] / simgear / metar / Fracpart.cpp
1 #include "Local.h"     /* standard header file */
2 #include "Metar.h"
3  
4 #pragma subtitle(" ")
5 #pragma page(1)
6 #pragma subtitle("subtitle - description                       ")
7 /********************************************************************/
8 /*                                                                  */
9 /*  Title:         fracPart                                         */
10 /*  Organization:  W/OSO242 - GRAPHICS AND DISPLAY SECTION          */
11 /*  Date:          13 Jun 1995                                      */
12 /*  Programmer:    CARL MCCALLA                                     */
13 /*  Language:      C/370                                            */
14 /*                                                                  */
15 /*  Abstract:      Convert a character string fraction into a       */
16 /*                 decimal (floating point) number.                 */
17 /*                                                                  */
18 /*  External Functions Called:                                      */
19 /*                 None.                                            */
20 /*                                                                  */
21 /*  Input:         string - a pointer to a character string frac-   */
22 /*                          tion.                                   */
23 /*  Output:        A decimal (floating point) number.               */
24 /*                                                                  */
25 /*  Modification History:                                           */
26 /*                 None.                                            */
27 /*                                                                  */
28 /********************************************************************/
29 #pragma page(1)
30  
31 float fracPart( char *string )
32 {
33  
34    /***************************/
35    /* DECLARE LOCAL VARIABLES */
36    /***************************/
37  
38    char buf[ 6 ],
39         *slash;
40  
41    float numerator,
42          denominator;
43  
44    /*************************/
45    /* START BODY OF ROUTINE */
46    /*************************/
47  
48    slash = strchr(string, '/');
49  
50    memset(buf , '\0', 6);
51    strncpy( buf, string, slash-string);
52  
53    numerator = (float) atoi(buf);
54  
55    memset(buf , '\0', 6);
56    strcpy( buf, slash+1);
57  
58    denominator = (float) atoi(buf);
59  
60    return (numerator/denominator);
61  
62 }
63