Navigation:  »No topics above this level«

Data Types

Print this Topic Previous pageReturn to chapter overviewNext page

DPlot_Plot, DPlot_PlotBitmap, DPlot_PlotToRect, and DPlot_AddData each pass arrays of single-precision floating point numbers to DPlot. In C and C#, these are arrays of type float, in Visual Basic jargon they are Single, and in FORTRAN they are REAL*4. Double precision (C double, VB Double, FORTRAN REAL*8) versions of these functions are identical other than the arrays and an "8" suffix for the function name: DPlot_Plot8, DPlot_PlotBitmap8, DPlot_PlotToRect8, and DPlot_AddData8. DPlot stores data in double-precision arrays, so the precision of data passed to DPlot using these functions will be preserved.

For most applications single precision is sufficient. A notable exception is passing date and time values in Excel's serial format: the resolution of the date May 20, 2004 (38127 in Excel serial format - see below) is about 3.3 minutes. In other words 12 noon on that date is indistinguishable from 3 minutes past noon if the date and time are represented with single precision. The resolution for the same date using double precision is about 0.37 microseconds.

DPLOTLIB Arguments

This documentation describes the argument lists of the DPLOTLIB functions using C syntax and data types. The equivalent data types in other languages are shown below.

 

* prefix

Indicates that the address of the argument, rather than the argument itself, is passed to the function. This is the default in FORTRAN. In Visual Basic this is equivalent to passing an argument ByRef. In C# this is equivalent to a ref prefix.
g77 users please note: As mentioned above, passing arguments by reference (that is, the address of the argument) is the default in FORTRAN. All other FORTRAN compilers can pass arguments by value by including interface definitions to whatever function/subroutine requires it. But g77 does not (at this writing) support interface definitions. To pass an argument by value in g77 use the %VAL(argument) form. This is required for calls to roughly half of the DPLOTLIB functions.

int

4-byte signed integer. INTEGER*4 in FORTRAN, Long in Visual Basic.

float

4-byte single-precision floating point number. REAL*4 in FORTRAN, Single in Visual Basic.

double

8-byte double-precision floating point number. REAL*8 in FORTRAN, Double in Visual Basic.

DWORD

4-byte unsigned integer. FORTRAN and Visual Basic do not have an exact equivalent, use INTEGER*4 and Long, respectively.

HWND

Handle to a window, 4-byte integer. Use INTEGER*4 in FORTRAN, Long in Visual Basic, IntPtr in VB.NET and C#.

HBITMAP

Handle to a bitmap, 4-byte integer. Use INTEGER*4 in FORTRAN, Long in Visual Basic, IntPtr in VB.NET and C#.

HENHMETAFILE

Handle to an enhanced metafile, 4-byte integer. Use INTEGER*4 in FORTRAN, Long in Visual Basic, IntPtr in VB.NET and C#.

LPSTR

Pointer to a null-terminated string of 8-bit Windows (ANSI) characters. CHARACTER in FORTRAN, String in Visual Basic. For FORTRAN, you must take special care to terminate character string arguments with a null character (ASCII 0) and pass the string by value rather than by reference. The latter is handled automatically in the interface code for all currently supported FORTRANs. Since this is not a part of the FORTRAN standard, the mechanism for passing strings by value will vary from compiler to compiler; consult your compiler documentation. Also be aware that all character strings returned by DPLOTLIB functions will be null-terminated. In Visual Basic, a null character is automatically appended to strings passed ByVal.

DPLOT

A DPLOT structure. A DPLOT structure contains format information for the graph: number of curves, number of points in each curve, line and symbol styles used, etc. This structure is defined in the header/include file accompanying the various source examples.

Excel 1900 Date System Serial Numbers

Although DPlot will display numbers along the axes using calendar dates and/or time of day, internally the data is always represented as double precision floating point numbers. Dates and date-and-time groups in DPlot use the same mechanism for storing this data as is used by Microsoft Excel: Excel's 1900 Date System. If your application passes dates to DPlot using DPlot_Plot or similar function, those dates must be represented using this format. The following code will convert a calendar date to an Excel serial number (day and month are 1-based; January=1, December=12):

if( Month > 2 )

    serial=(int)(365.25*year)+(int)(30.6001*(month+1))+day-694037;

else

    serial=(int)(365.25*(year-1))+(int)(30.6001*(month+13))+day-694037;

Time of day may be added to a serial number date simply by adding the time as a fractional part of the day. 0=midnight, 0.5=noon, etc.

 

 

 


Page url: http://www.dplot.com/lib/index.htm?datatypes.htm