[Info-vax] BASIC and Floating Point (was: Re: Roadmap)

Stephen Hoffman seaohveh at hoffmanlabs.invalid
Tue Jan 8 22:19:37 EST 2019


On 2019-01-08 08:53:13 +0000, Dave Froble said:

> John, there are two Basic functions that map a real to a string, and a 
> string to a real.  This is used to store data as a string, and retrieve 
> the data.
> 
> CVTF$() takes a real and produces an 8-byte string
> CVT$F() takes a string from above and returns the real number

FWIW... Per the BASIC docs: "CVT functions are supported only for 
compatibility with BASIC-PLUS. It is recommended that you use the BASIC 
dynamic mapping feature or multiple MAP statements for new program 
development."

> So now the question.  Do there functions work for any real, or just 
> D_FLOAT?  I'm thinking it might be just D_FLOAT.

It's whatever the default is for the compilation.  The doc expressly 
avoids mentioning the floating point format too, which usually means 
that assumptions can be hazardous.

Use of the OpenVMS RTL calls including CVT$FTOF, CVT$CONVERT_FLOAT, 
LIB$CVT_DX_DX and friends are the usual path for floating point 
conversions, if BASIC can't easily manage the operations directly.

IEEE 754 float (S_Float single, T_Float double, etc) would usually be 
the preferred format for most binary storage of floating point values, 
and that'll work across little-endian systems.

I haven't seen much on OpenVMS that references the IEEE floating point 
binary interchange formats unfortunately, nor does OpenVMS support IEEE 
754-2008 quite yet.

And I'd usually prefer exporting to text for archival purposes.

Related:
http://neilrieck.net/misc/pdf/vms-docs/i64-floating-pt-wp.pdf
http://neilrieck.net/misc/pdf/vms-docs/t_and_s_float.pdf
etc.



-- 
Pure Personal Opinion | HoffmanLabs LLC 




More information about the Info-vax mailing list