HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


floor

Returns the largest integer less than or equal to the argument.

Format

#include <math.h>

double floor (double x);

float floorf (float x); (INTEGRITY SERVERS, ALPHA)

long double floorl (long double x); (INTEGRITY SERVERS, ALPHA)


Argument

x

A real value.

Return Value

n The largest integer less than or equal to the argument.

fma (INTEGRITY SERVERS, ALPHA)

Computes (x * y) + z, rounded as one ternary operation.

Format

#include <math.h>

double fma (double x, double y, double z);

float fmaf (float x, float y, float z);

long double fmal (long double x, long double y, long double z);


Argument

x,y,z

Real values.

Description

The fma functions compute (x * y) + z, rounded as one ternary operation: the value is computed as if to infinite precision and rounded once to the result format, according to the rounding mode characterized by the value of FLT_ROUNDS.

Return Values

n Upon success, ( x * y) + z, rounded as one ternary operation.
NaN x or y is NaN; errno is set to EDOM.

fmax (INTEGRITY SERVERS, ALPHA)

Returns the maximum numeric value of its arguments.

Format

#include <math.h>

double fmax (double x, double y);

float fmaxf (float x, float y);

long double fmaxl (long double x, long double y);


Argument

x

A real value.

y

A real value.

Description

The fmax functions determine the maximum numeric value of their arguments. NaN arguments are treated as missing data: if one argument is a NaN and the other numeric, then the numeric value is returned.

Return Values

n Upon success, the maximum numeric value of the arguments. If just one argument is a NaN, the other argument is returned.
NaN Both x and y are NaNs.

fmin (INTEGRITY SERVERS, ALPHA)

Returns the minimum numeric value of its arguments.

Format

#include <math.h>

double fmin (double x, double y);

float fminf (float x, float y);

long double fminl (long double x, long double y);


Argument

x

A real value.

y

A real value.

Description

The fmin functions determine the minimum numeric value of their arguments. NaN arguments are treated as missing data: if one argument is a NaN and the other numeric, then the numeric value is returned.

Return Values

n Upon success, the minimum numeric value of the arguments. If just one argument is a NaN, the other argument is returned.
NaN Both x and y are NaNs.

fmod

Computes the floating-point remainder.

Format

#include <math.h>

double fmod (double x, double y);

float fmodf (float x, float y); (INTEGRITY SERVERS, ALPHA)

long double fmodl (long double x, long double y); (INTEGRITY SERVERS, ALPHA)


Arguments

x

A real value.

y

A real value.

Description

The fmod functions return the floating-point remainder of the first argument divided by the second. If the second argument is 0, the function returns 0.

Return Values

x The value f, which has the same sign as the argument x, such that x == i * y + f for some integer i, where the magnitude of f is less than the magnitude of y.
0 Indicates that y is 0.

fopen

Opens a file by returning the address of a FILE structure.

Format

#include <stdio.h>

FILE *fopen (const char *file_spec, const char *a_mode); (ANSI C)

FILE *fopen (const char *file_spec, const char *a_mode, ...); (HP C EXTENSION)


Arguments

file_spec

A character string containing a valid file specification.

a_mode

The access mode indicator. Use one of the following character strings: "r", "w", "a", "r+", "w+", "rb", "r+b", "rb+", "wb", "w+b", "wb+", "ab", "a+b", "ab+", or "a+".

These access modes have the following effects:

The update access modes allow a file to be opened for both reading and writing. When used with existing files, "r+" and "a+" differ only in the initial positioning within the file. The modes are:

...

Optional file attribute arguments. The file attribute arguments are the same as those used in the creat function. For more information, see the creat function.

Description

If a version of the file exists, a new file created with fopen inherits certain attributes from the existing file unless those attributes are specified in the fopen call. The following attributes are inherited:
Record format
Maximum record size
Carriage control
File protection

If you specify a directory in the filename and it is a search list that contains an error, HP C for OpenVMS Systems interprets it as a file open error.

The file control block can be freed with the fclose function, or by default on normal program termination.


Return Values

x File pointer.
NULL Indicates an error. The constant NULL is defined in the <stdio.h> header file to be the NULL pointer value. The function returns NULL to signal the following errors:
  • File protection violations
  • Attempts to open a nonexistent file for read access
  • Failure to open the specified file

fp_class (INTEGRITY SERVERS, ALPHA)

Determines the class of IEEE floating-point values.

Format

#include <math.h>

int fp_class (double x);

int fp_classf (float x);

int fp_classl (long double x);


Argument

x

An IEEE floating-point number.

Description

The fp_class functions determine the class of the specified IEEE floating-point number, returning a constant from the <fp_class.h> header file. They never cause an exception, even for signaling NaNs (Not-a-Number). These functions implement the recommended class(x) function in the appendix of the IEEE 754-1985 standard for binary floating-point arithmetic. The constants in <fp_class.h> refer to the following classes of values:
FP_SNAN Signaling NaN (Not-a-Number)
FP_QNAN Quiet NaN
FP_POS_INF +Infinity
FP_NEG_INF - Infinity
FP_POS_NORM positive normalized
FP_NEG_NORM negative normalized
FP_POS_DENORM positive denormalized
FP_NEG_DENORM negative denormalized
FP_POS_ZERO +0.0 (positive zero)
FP_NEG_ZERO - 0.0 (negative zero)

Return Value

x A constant from the <fp_class.h> header file.

fpathconf

Retrieves file implementation characteristics.

Format

#include <unistd.h>

long int fpathconf (int filedes, int name);


Arguments

filedes

An open file descriptor.

name

The configuration attribute to query. If this attribute is not applicable to the file specified by the filesdes argument, fpathconf returns an error.

Description

The fpathconf function allows an application to retrieve the characteristics of operations supported by the file system underlying the filenamed by the filesdes argument. Read, write, or execute permission of the named file is not required, but you must be able to search all directories in the path leading to the file.

Symbolic values for the name argument are defined in the <unistd.h> header file as follows:
_PC_LINK_MAX The maximum number of links to the file. If the filedes argument refers to a directory, the value returned applies to the directory itself.
_PC_MAX_CANON The maximum number of bytes in a canonical input line. This is applicable only to terminal devices.
_PC_MAX_INPUT The number of types allowed in an input queue. This is applicable only to terminal devices.
_PC_NAME_MAX Maximum number of bytes in a filename (not including a terminating null). The byte range value is between 13 and 255. This is applicable only to a directory file. The value returned applies to filenames within the directory.
_PC_PATH_MAX Maximum number of bytes in a pathname (not including a terminating null). The value is never larger than 65,535. This is applicable only to a directory file. The value returned is the maximum length of a relative pathname when the specified directory is the working directory.
_PC_PIPE_BUF Maximum number of bytes guaranteed to be written atomically. This is applicable only to a FIFO. The value returned applies to the referenced object. If the path argument refers to a directory, the value returned applies to any FIFO that exists or can be created within the directory.
_PC_CHOWN_RESTRICTED The value returned applies to any files (other than directories) that exist or can be created within the directory. This is applicable only to a directory file.
_PC_NO_TRUNC Returns 1 if supplying a component name longer than allowed by NAME_MAX causes an error. Returns 0 (zero) if long component names are truncated. This is applicable only to a directory file.
_PC_VDISABLE This is always 0 (zero); no disabling character is defined. This is applicable only to a terminal device.


Return Values

x The resultant value for the configuration attribute specified in the name argument.
- 1 Indicates an error; errno is set to one of the following values:
  • EINVAL -- The name argument specifies an unknown or inapplicable characteristic.
  • EBADF -- the filedes argument is not a valid file descriptor.

fprintf

Performs formatted output to a specified file.

Format

#include <stdio.h>

int fprintf (FILE *file_ptr, const char *format_spec, ...);


Arguments

file_ptr

A pointer to the file to which the output is directed.

format_spec

A pointer to a character string that contains the format specification. For more information on format specifications and conversion characters, see Chapter 2.

...

Optional expressions whose resultant types correspond to conversion specifications given in the format specification.

If no conversion specifications are given, the output sources can be omitted. Otherwise, the function calls must have exactly as many output sources as there are conversion specifications, and the conversion specifications must match the types of the output sources.

Conversion specifications are matched to output sources in left-to-right order. Any excess output sources are ignored.


Example

An example of a conversion specification follows:


#include <stdio.h> 
 
main() 
{ 
   int  temp = 4, temp2 = 17; 
 
   fprintf(stdout, "The answers are %d, and %d.", temp, temp2); 
} 

This example outputs the following to the stdout file:


The answers are 4, and 17. 

For a complete description of the format specification and the output source, see Chapter 2.


Return Values

x The number of bytes written, excluding the null terminator.
Negative value Indicates an error. The function sets errno to one of the following:
  • EILSEQ -- Invalid character detected.
  • EINVAL -- Insufficient arguments.
  • ENOMEM -- Not enough memory available for conversion.
  • ERANGE -- Floating-point calculations overflow.
  • EVMSERR -- Nontranslatable OpenVMS error. vaxc$errno contains the OpenVMS error code. This might indicate that conversion to a numeric value failed because of overflow.
  The function can also set errno to the following as a result of errors returned from the I/O subsystem:
  • EBADF -- The file descriptor is not valid.
  • EIO -- I/O error.
  • ENOSPC -- No free space on the device containing the file.
  • ENXIO -- Device does not exist.
  • EPIPE -- Broken pipe.
  • ESPIPE -- Illegal seek in a file opened for append.
  • EVMSERR -- Nontranslatable OpenVMS error. vaxc$errno contains the OpenVMS error code. This indicates that an I/O error occurred for which there is no equivalent C error code.

fputc

Writes a character to a specified file.

Format

#include <stdio.h>

int fputc (int character, FILE *file_ptr);


Arguments

character

An object of type int .

file_ptr

A file pointer.

Description

The fputc function writes a single character to the specified file and returns the character.

Compiling with the __UNIX_PUTC macro defined enables an optimization that uses a faster, inlined version of this function.

See also the fputc_unlocked function and the putc macro.


Return Values

x The character written to the file. Indicates success.
EOF Indicates an output error.

fputc_unlocked (INTEGRITY SERVERS, ALPHA)

Same as the fputc function, except used only within a scope protected by flockfile and funlockfile .

Format

#include <stdio.h>

int fputc_unlocked (int character, FILE *file_ptr);


Arguments

character

The character to be written. An object of type int .

file_ptr

A file pointer.

Description

See the putc_unlocked macro.

Compiling with the __UNIX_PUTC macro defined enables an optimization that uses a faster, inlined version of this function.

See also flockfile , ftrylockfile , and funlockfile .


Return Values

n The returned character.
EOF Indicates the end-of-file or an error.

fputs

Writes a character string to a file without copying the string's null terminator (\0).

Format

#include <stdio.h>

int fputs (const char *str, FILE *file_ptr);


Arguments

str

A pointer to a character string.

file_ptr

A file pointer.

Description

Unlike puts , the fputs function does not append a new-line character to the output string.

See also puts .


Return Values

Nonnegative value Indicates success.
EOF Indicates an error.

fputwc

Converts a wide character to its corresponding multibyte value, and writes the result to a specified file.

Format

#include <wchar.h>

wint_t fputwc (wint_t wc, FILE *file_ptr);


Arguments

wc

An object of type wint_t .

file_ptr

A file pointer.

Description

The fputwc function writes a wide character to a file and returns the character.

See also putwc .


Return Values

x The character written to the file. Indicates success.
WEOF Indicates an output error. The function sets errno to the following:
  • EILSEQ -- Invalid wide-character code detected.

The function can also set errno to the following as a result of errors returned from the I/O subsystem:

  • EBADF -- The file descriptor is not valid.
  • EIO -- I/O error.
  • ENOSPC -- No free space on the device containing the file.
  • ENXIO -- Device does not exist.
  • EPIPE -- Broken pipe.
  • ESPIPE -- Illegal seek in a file opened for append.
  • EVMSERR -- Nontranslatable OpenVMS error. vaxc$errno contains the OpenVMS error code. This indicates that an I/O error occurred for which there is no equivalent C error code.


Previous Next Contents Index