BUG: QuickBasic Can't Print Lightspeed C's SANE Floating-Point (46030)
This article was previously published under Q46030
SYMPTOMS
QuickBasic's NumToASCII and PrintNumber routines for support of pure
code (MBPC) libraries cannot use Think's LightspeedC floating-point
numbers.
Microsoft has confirmed this limitation in Microsoft QuickBasic
Version 1.00 for the Macintosh system. Microsoft is researching
this problem and will post new information as it becomes available.
MORE INFORMATION
There are two reasons for this incompatibility. First, QuickBasic 1.00
uses the IEEE floating-point format. LightspeedC uses SANE (Standard
Apple Numeric Environment), a common floating-point format for
Macintosh languages. Second, because a pure code resource must be
totally self contained, the C startup code cannot be included and,
therefore, is not executed when these routines are CALLed. Part of the
function of the C startup code is to initialize floating-point
literals.
The support library provided for inter-language calling from
QuickBasic is called BasicLib.Lib. Two routines in this library,
NumToASCII and PrintNumber, correctly use C's integer and long integer
types but cannot correctly convert either the float or the double.
NumToASCII and PrintNumber are documented on Pages 465 and 466 of
"Microsoft QuickBasic for Macintosh : Language Reference."
The following code example uses Think's LightspeedC (sold by Symantec
Corporation) to create a "Code Resource" that demonstrates the
problem. In LightspeedC, the Code Resource should be named
"PrintTheNumber" and the library should be named "PrintTheNumber" as
well.
Code Example
/*******
PrintNum.c
*********/
#include <BasicLSC.h>
#define LONG_TYPE 6
#define DOUBLE_TYPE 5
#define SNGLE_TYPE 4
#define INT_TYPE 3
PUBLIC VOID main()
{
/* dimension the variables */
/* Variant records and their pointers. */
NUMREC thelongptr,thesingleptr,thedoubleptr;
/* Local work varialbes. */
StringPtr thestring;
short int_var;
long long_var;
float single_var;
double double_var;
SAVEREGS();
/* Initialize the pointers. */
theintptr = &theint;
thelongptr = &thelong;
thesingleptr = &thesingle;
thedoubleptr = &thedouble;
/* Assign them some values */
int_var = 32700;
theint.Int= int_var;
long_var = 500000;
thelong.Long = long_var;
single_var = (float)12.3456789;
thesingle.Sngle = single_var;
double_var = (double)12.3456789;
thedouble.Doble = double_var;
/*******************************************************/
/* Print the numbers using NumToASCII and PrintCString */
/*******************************************************/
NumToASCII(INT_TYPE,(NUMRECPTR)theintptr,&thestring);
OutNewLine();
NumToASCII(LONG_TYPE,(NUMRECPTR)thelongptr,&thestring);
OutNewLine();
NumToASCII(SNGLE_TYPE,(NUMRECPTR)thesingleptr,&thestring);
OutNewLine();
NumToASCII(DOUBLE_TYPE,(NUMRECPTR)thedoubleptr,&thestring);
OutNewLine();
/**************************************************/
/* Print them out using the PrintNumber function. */
/**************************************************/
PrintNumber(INT_TYPE,theintptr);
OutNewLine();
PrintNumber(LONG_TYPE,thelongptr);
OutNewLine();
PrintNumber(SNGLE_TYPE,thesingleptr);
OutNewLine();
PrintNumber(DOUBLE_TYPE,thedoubleptr);
OutNewLine();
RESTREGS();
}
/*********************** END C PROGRAM *************/
'**********************************************
'* MBPC test *
'* Basic program to call MBPC routine above. *
'* This program calls the C pure code library *
'* routine to test the PrintNumber and *
'* NumToASCII functions contained in the *
'* BasicLib.Lib library. *
'**********************************************
LIBRARY "PrintTheNumber"
IF SYSTEM(4) THEN CALL LIBINIT
CALL PrintTheNumber
END
Modification Type: |
Minor |
Last Reviewed: |
1/8/2003 |
Keywords: |
kbbug KB46030 |
|