Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
cspice_intmax

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries

Abstract


   CSPICE_INTMAX returns the value of the largest (positive) number
   representable in an integer variable.

I/O


   Given:

      None.

   the call:

      [intmax] = cspice_intmax

   returns:

      intmax   the value of the largest (positive) number that can be
               represented in an integer variable.

               [1,1] = size(intmax); int32 = class(intmax)

               This varies from machine to machine.

Parameters


   None.

Examples


   Any numerical results shown for this example may differ between
   platforms as the results depend on the SPICE kernels used as input
   and the machine specific arithmetic implementation.

   1) Obtain the integer part of a double precision number. If the
      integer component of the number is out of range, avoid
      overflow by making it as large or small as possible.


      Example code begins here.


      function intmax_ex1()

         %
         % Define a set of three numbers, two of them having an
         % integer component that is out of range.
         %
         number = [2.e40, -1.5e35, 1.6]';

         for i=1:3

            fprintf( 'Double precision number: %8.1e\n', number(i) )

            %
            % If the integer component is out of range, avoid
            % overflow by making it as large as possible.
            %
            if ( number(i) > double( cspice_intmax ) )

               fprintf( '   Overflow! Greater than cspice_intmax.\n' )
               ivalue = cspice_intmax;

            elseif ( number(i) < double( cspice_intmin ) )

               fprintf( '   Overflow! Smaller than cspice_intmin.\n' )
               ivalue = cspice_intmin;

            else

               ivalue = floor( number(i) );

            end

            fprintf( '   Integer part        :  %d\n', ivalue )
            fprintf( '\n' )

         end


      When this program was executed on a Mac/Intel/Octave5.x/64-bit
      platform, the output was:


      Double precision number:  2.0e+40
         Overflow! Greater than cspice_intmax.
         Integer part        :  2147483647

      Double precision number: -1.5e+35
         Overflow! Smaller than cspice_intmin.
         Integer part        :  -2147483648

      Double precision number:  1.6e+00
         Integer part        :  1


Particulars


   None.

Exceptions


   Error free.

Files


   None.

Restrictions


   None.

Required_Reading


   MICE.REQ

Literature_References


   [1]  "Programming in VAX FORTRAN", Digital Equipment Corporation,
        September 1984, Appendix C, FORTRAN Data Representation,
        page C-2.

   [2]  "Microsoft FORTRAN Reference", Microsoft Corporation
        1989, Section 1.3.1, page 10.

   [3]  "Sun FORTRAN Programmer's Guide, Sun Microsystems,
        Revision A of 6 May 1988, Appendix F, Manual Pages for
        FORTRAN, page 306 (RANGE).

   [4]  "Language Systems FORTRAN Reference Manual", Language
        Systems Corporation, version 1.2.1, page 3-2.

   [5]  "Lahey F77L EM/32 Programmers Reference Manual",
        version 4.0, page 95.

   [6]  "FORTRAN/9000 Reference HP 9000 Series 700 Computers",
        First Edition, June 1991, Hewlett Packard Company, page 4-4.

   [7]  "SGI Fortran 77 Programmer's Guide", Document number
        007-0711-030, page 2-2.

   [8]  "Language Reference Manual", Absoft Fortran V3.2, 1993,
        page 3-14, section 3.6.1.5. (for the NeXT)

   [9]  "Unix/VMS Compatibility Libraries", Absoft Fortran V3.2,
        1993; Chapter 3, Support Libraries, page 3-14, inmax.
        (for the NeXT)

Author_and_Institution


   J. Diaz del Rio     (ODC Space)

Version


   -Mice Version 1.0.0, 25-AUG-2021 (JDR)

Index_Entries


   largest integer number


Fri Dec 31 18:44:25 2021