FTOC()

FTOC()

Converts a floating point number into a special 8-byte string

Syntax

       FTOC(<nFloatingPointNumber>) --> cFloatingPointNumber

Arguments

<nFloatingPointNumber> Designate any Clipper number.

Returns

FTOC() return a string with the size of DOUBLE.

ATTENTION: different implementations or platforms of Harbour, they could produce different format in the string returned by FTOC().

Description

Harbour internal numbers in Floating Point are stored in data type DOUBLE. FTOC() returns these bits as an string. In this way, numbers con be saved more compactly.

Note

. The XTOC() function converts floating point numbers in the same way.

Example

       It is not useful to display the return value on the screen:
           NumberString  :=  FTOC(274711.335)      // 8 byte string

Platforms

All

Files

Source is ftoc.c, library is libct.

See also

CTOF(), XTOC()

CToF()

CToF()

Converts a special 8-byte string into a floating point number

 

Syntax

       CToF( <cFloatingPointNumber> ) --> nFloatingPointNumber

Arguments

<cFloatingPointNumber> Designate a string that contains a Harbour number in flotaing point format.

Returns

CToF() return the floating point number that corresponds to the string passed.

ATTENTION: different implementations or platforms of Harbour, they could produce different format in the string returned by FTOC().

Description

Character strings created with FTOC() or XTOC() are convert into Harbour floating point number Note that when you use XTOC(), character strings or portions of character strings, can be switched back, if they have been displayed as Harbour floating point numbers.

Examples

       .  Change a number and then change it back:
              CToF(FTOC(1234.55))        // Result:  1234.55
           .  This also works for XTOC():
              ? CToF(XTOC(1234.55))      // Result:  1234.55

Platforms

All

Files

Source is ftoc.c, library is libct.

Seealso

FToC(), XToC()

Conversion Functions

Harbour Conversion Functions

Bin2I Convert signed short encoded bytes into Harbour numeric
Bin2L Convert signed long encoded bytes into Harbour numeric
Bin2U Convert unsigned long encoded bytes into Harbour numeric
Bin2W Convert unsigned short encoded bytes into Harbour numeric
BitToC Converts position-dependent bits into characters
BinToDec Converts a Binary Value to Decimal
CToBit Converts a character string into a bit pattern
CToF Converts a special 8-byte string into a floating point number
CToN Converts a numeric string into a different base
DecToBin Converts a Decimal Value to Binary
DecToHexa Converts a Decimal Value to Hexa
DecToOctal Converts a Decimal Value to Octal
Fahrenheit Temperature conversion Celsius to Fahrenheit
FToC Converts a floating point number into a special 8-byte string
HexaToDec Converts a Hexa Value to Decimal
I2Bin Convert Harbour numeric into signed short encoded bytes
L2Bin Convert Harbour numeric into signed long encoded bytes
NToC Converts the numbers in a digit string into a different number base
OctalToDec Converts a Octal Value to Decimal
U2Bin Convert Harbour numeric into unsigned long encoded bytes
W2Bin Convert Harbour numeric into unsigned short encoded bytes
Word Converts double to integer values
XTOC Convert an expression to character type string

CT_XTOC

 XTOC()
 Converts an expression of any data type into a string
------------------------------------------------------------------------------
 Syntax

     XTOC(<expValue>) --> cValue

 Argument

     <expValue>  Designates an expression of any desired data type.

 Returns

     XTOC() returns a character string version of the <expValue> parameter.

 Description

     At first glance, the XTOC() function does not appear to accomplish
     anything that cannot be done with the other functions.  However, the
     advantage lies in the fact that you do not have to pay attention to the
     input data types.  For example, you can convert the data in every field
     within a loop into a string.  You could then link these into a longer
     string and use them to index or for comparisons.

     Each data type always returns a string with a particular fixed length:

     Table 13-9: Resulting String
     ------------------------------------------------------------------------
     Data Type    Result Length
     ------------------------------------------------------------------------
     Numeric      8
     Logical      1
     Date         8
     String       Unchanged
     ------------------------------------------------------------------------

 Note

     .  The index string cannot be longer than 256 characters.

 Examples

     .  In the case of logical parameters, XTOC() works like LTOC():

        ? XTOC(.T.)                              // "T"
        ? XTOC(.F.)                              // "F"

     .  Numeric values always return an 8-byte string:

        ? XTOC(0)                                // Length 8
        ? XTOC(9.9)                              // Ditto
        ? XTOC(-9.9)                             // Ditto
        ? XTOC(99)                               // Ditto
        ? XTOC(-99)                              // Ditto

     .  A string returns the same string:

        ? XTOC("123ABCabc")                      // "123ABCabc"

     .  A date returns the ANSI date:

        ? XTOC(CTOD("12/31/99"))                 // "19991231"
        ? XTOC(CTOD("01/01/00")                  // "19000101"

     .  An empty or false date returns an empty string rather than a
        null string:

        ? XTOC(CTOD("  /  /  ")                  // "        "
        ? XTOC(CTOD("77/77/77")                  // "        "

     .  Show a function where all the fields in a database are
        combined into one string.  This way, you can do a complete comparison
        of the two data strings:

        FUNCTION STRINGREC
           PRIVATE nI, nFieldNo, cField, cStringRec
           cStringRec := ""
           nFieldNo   := FCOUNT()                // Number of fields
           FOR nI = 1 to nFieldNo
             cField          := FIELD(nI)        //  Field name
             cStringRec := cStringRec + XTOC(&cField)
           NEXT nI
           RETURN (cStringRec)

See Also: CTOF()



Tools – Miscellaneous Functions

Introduction Miscellaneous Functions
ALLOFREE()*  Determines the maximum memory size allocation
BLANK()      Creates a blank value for each data type
COMPLEMENT() Forms the complement value of a data type
DATATYPE()*  Determines the data type of a variable or UDF
GETTIC()     Determines the number of timer ticks
KBDDISABLE() Locks/unlocks the keyboard
KBDEMULATE() Inserts characters into BIOS keyboard buffer to emulate input
KBDSPEED()   Sets keyboard auto repeat speed
KBDSTAT()    Tests for key shift state status, such as Ctrl and Shift
KBDTYPE()    Determines the type of keyboard in use
KEYSEC()     Triggers a key trap after a time delay
KEYTIME()    Triggers a key trap at a specific clock time
MILLISEC()   Time delay in milliseconds
NUL()        Converts the value returned by a function into a null string
SCANKEY()    Queries scan code of keyboard input
SETTIC()     Increases number of time ticks
SHOWKEY()    Continuously displays the INSERT and LOCK status
SOUND()      Creates tones (melodies) by designating frequency and duration
SPEED()      A comparison value used to determine the processor speed
STACKFREE()  Determines the remaining stack space
TOOLVER()    Queries the version number of the Clipper Tools in use
XTOC()       Converts an expression of any data type into a string