Table of contents
CSPICE_INTMIN returns the value of the smallest (negative) number
representable in an integer variable.
Given:
None.
the call:
[intmin] = cspice_intmin
returns:
intmin the value of the smallest (negative) number that can be
represented in an integer variable.
[1,1] = size(intmin); int32 = class(intmin)
None.
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 intmin_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
None.
Error free.
None.
None.
MICE.REQ
[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)
J. Diaz del Rio (ODC Space)
-Mice Version 1.0.0, 25-AUG-2021 (JDR)
smallest integer number
|