Mantissa()

Mantissa()

Evaluate the mantissa of a floating point number

Syntax

       Mantissa( <nFloatingPointNumber> ) --> nMantissa

Arguments

<nFloatingPointNumber> Designate any Harbour number.

Returns

Mantissa() returns the mantissa of the <nFloatingPointNumber> number.

Description

This function supplements Exponent() to return the mantissa of the <nFloatingPointNumber> number.

Notes

The mantissa value can be 0 or in the range of 1 to 2. The following calculation reproduces the original value: Mantissa( <nFloatingPointNumber> ) * 2 ˆ Exponent( <nFloatingPointNumber> ) = <nFloatingPointNumber>

Example

       Display the mantissa for the following values:
           ? Mantissa(0)            // Result:  0.00
           ? Mantissa(100)          // Result:  1.56
           ? Mantissa(INFINITY)     // Result:  2.00
           ? Mantissa(0.01)         // Result:  1.28
           ? Mantissa(-100)         // Result: -1.56
           ? Mantissa(-0.01)        // Result: -1.28
           ? Mantissa(-1.01)        // Result: -1.01
           ? Mantissa(-2.01)        // Result: -1.01

Compliance

Mantissa() is compatible with CT3’s Mantissa().

Platforms

All

Files

Source is exponent.c, library is libct.

Seealso

Exponent()

LastDayOM()

LastDayOM()

Determines the number of days in a month

Syntax

       LastDayOM([<dDate|nMonth>]) --> nDaysInMonth

Argument

<dDate|nMonth> Designates either a date or the number of a month.The default is the system date.

Returns

LastDayOM() returns the number of days in the month specified by <dDate|nMonth>.

Description

<dDate|nMonth> can be a date or a month number. If empty uses the system date. If nMonth is a 2, lastdayom() will not know if it is a leap year or not. If dDate is invalid, returns 0 To administer due dates and other similar dates, it is useful to know the number of days that remain in a month. Specify either the day’s date or month as a parameter, and you get the length of the month in days. If you subtract the number of days until today’s date, you are left with the days that remain until month end.

Note

. Without the <dDate|nMonth> parameter, the function automatically uses the system date. If there is an invalid number of months, LastDayOM() returns 0 as an error code.

Example

       How many days remain before the end of the month?
           ? DATE(), LastDayOM()
           ? "There are " + STR(LastDayOM() - DAY( DATE() ), 2) +;
              " days until the end of the month"

Compliance

LastDayOM() is compatible with CT3’s LastDayOM().

Platforms

All

Files

Source is dattime2.prg, library is libct.

Seealso

EOM()

JustRight()

JustRight()

Move characters from the end to the beginning of a string

Syntax

       JustRight( <[@]cString>, [<cChar>|<nChar>] ) -> cJustifiedString

Arguments

<cString> [@] Designates the string that is processed. <cCharacter|nCharacter> Designates the character that is moved from the end of the <cString> to the beginning. The default value is a space, CHR(32).

Returns

The processed <cString> is returned.

Description

JustRight() moves the characters specified in <cCharacter| nCharacter> from the end of a character string to the beginning. Then the remaining text in the character string is right justified, without affecting the length.

Notes

. If the <cCharacter|nCharacter> parameter is not specified, spaces are automatically moved. . The return value for this function can be suppressed by implementing CSETREF() to save room in working memory.

Examples

       .  Move the blanks
              ? JustRight("123   ")           // "   123"
           .  Move the "." character
              ? JustRight("123..", ".")       // "..123 "

Compliance

JustRight() is compatible with CT3’s JustRight().

Platforms

All

Files

Source is justify.c, library is libct.

Seealso

JustLeft(), CSetRef(), Introduction

JustLeft()

JustLeft()

Moves characters from the beginning to the end of a string

Syntax

       JustLeft( <[@]cString>, [<cChar>|<nChar>] ) -> cJustifiedString

Arguments

<cString> [@] Designates the string that is processed. <cCharacter|nCharacter> Designates the character that is moved from the beginning of the <cString> to the end. The default value is a space, CHR(32).

Returns

The processed <cString> is returned.

Description

JustLeft() moves the characters specified in <cCharacter|nCharacter> from the beginning of a character string to the end. Then the remaining text in the character string is left justified, without affecting the length.

Notes

. If the <cCharacter|nCharacter> parameter is not specified, spaces are automatically moved. . The return value for this function can be suppressed by implementing CSETREF() to save room in working memory.

Examples

       .  Move the blanks:
              ? JustLeft("   123")              // "123   "
           .  Move the "." character:
              ? JustLeft("..123","." )          // "123.."

See also

JustRight(), CSetRef(), Introduction

ISLEAP()

ISLEAP()

Tests if a specific year is a leap year

Syntax

       ISLEAP([<dDate>]) --> lLeapYear

Argument

<dDate> Designates whether or not the specified date is in a leap year. The default is the system date.

Returns

ISLEAP() returns .T. when <dDate> lies in a leap year; otherwise, it returns .F..

Description

A number of technical financial calculations need to know if a year has 365 or 366 days. ISLEAP() determines this.

Note

. When parameters are missing, the function automatically uses the system date. You must adhere to all rules for leap year tests. In the rare occurrence of a century change, the function also returns a correct result.

Examples

        ? Date(), IsLeap()
           ? AddMonth( 12 ), IsLeap(AddMonth( 12))
          ? AddMonth( -12 ), IsLeap(AddMonth( -12))

Compliance

ISLEAP() is compatible with CT3’s ISLEAP().

Platforms

All

Files

Source is dattime2.prg, library is libct.

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()

EOY()

EOY()

Last date Of Year

Syntax

       EOY( [<dDate>] ) -> dDateEndOfYear

Argument

[<dDate>] Date to find last day of year, default is DATE()

Returns

<dDateEndOfYear> Last date Of Year of given date

Example

       SET DATE ANSI
       ? EOY( hb_SToD( "20000101" ) ) // -> "2000.12.31"
       ? EOY( hb_SToD( "20010101" ) ) // -> "2001.12.31"
       *--------------------
       PROC MAIN()
             SETMODE( 25, 80 )
             CLS
             SET DATE GERM
             SET CENT ON
             ? "Today is ", DATE()
             ? "Last day of this year ", EoY()
             ? "Remaining days in the current year", EoY() - DATE()
             ?
             WAIT "EOF EoY.prg"
          RETURN // MAIN

Compliance

EOY() is compatible with CT3’s EOY().

Platforms

All

Files

Source is datetime.prg, library is libct.

See also

BOM(), EOM(), BOQ(), EOQ(), BOY()

EoQ()

EoQ()

Date of end of quarter

Syntax

       EoQ( [<dDate>] ) -> dDateEndOfQ

Argument

[<dDate>] Date to find end of quarter, default is DATE()

Returns

<dDateEndOfQuarter> Date of end of quarter containing given date

Example

       PROC MAIN()
              SETMODE( 25, 80 )
              CLS
              SET DATE GERM
              SET CENT ON
              ? "Today is ", DATE()
              ? "Last day of this quarter
              ? "Days remaininng in the cu
              ?
              WAIT "EOF EOQ.prg"
           RETURN // MAIN

Compliance

EOQ() is compatible with CT3’s EOQ().

Platforms

All

Files

Source is datetime.prg, library is libct.

See also

BOM(), EOM(), BOQ(), BOY(), EOY()

EOM()

EOM()

End Of Month

Syntax

       EOM( [<dDate>] ) -> <dDateEndOfMon

Argument

[<dDate>] Date to find last day

Returns

<dDateEndOfMonth> Last date Of Month

Examples

       SET DATE ANSI
       ? EOM( hb_SToD( "20000101" ) ) // -> "2000.01.31"
       ? EOM( hb_SToD( "20000201" ) ) // -> "2000.02.29"
       PROC MAIN()
            SETMODE( 25, 80 )
            CLS
            SET DATE GERM
            SET CENT ON
            ? "Today is ", DATE()
            ? "Last day of this month ", EOM()
            ? "Remaining days in the current month:", EOM() - DATE() 
            ?
            WAIT "EOF EOM.prg"
         RETURN // MAIN
/*
Today is : 04.07.2013
Last day of this month : 31.07.2013
Remaining days in the current month: 27
EOF EOM.prg
*/

Compliance

EOM() is compatible with CT3’s EOM().

Platforms

All

Files

Source is datetime.prg, library is libct.

See also

BOM(), BOQ(), EOQ(), BOY(), EOY()

DOY()

DOY()

Determines the day of the year for a specific date

Syntax

       DMY( [<dDate>] ) -> nDayOfYear

Argument

<dDate> Designates which date to use to calculate the day of the year. The default is the system date.

Returns

DOY() returns a calendar day number that specifies which day of the year <dDate> represents.

Description

Determines the day of the year for a specific date if dDate is invalid, returns 0 If you frequently work with time periods, then this function is quite useful. DOY() lets you assign a calendar day number to a date that relates to the beginning of the year.

Note

. When no date is specified, DOY() uses the system date. January 1 is always 1, December 31 is 366 in a leap year; otherwise, it is 365. An empty date returns a 0 result.

Example

      ? DOY( hb_SToD( "20000131" ) ) // -> 31
      ? DOY( hb_SToD( "20000220" ) ) // -> 51

Compliance

DOY() is compatible with CT3’s DOY().

Platforms

All

Files

Source is dattime2.prg, library is libct.

Seealso

WOY()