?? genfloat.c
字號:
/* fpopt/genfloat.c, pl_FPE_common, pl_linux 12/12/03 16:18:27
*----------------------------------------------------------------------------
*
* Copyright (C) 2003 IBM Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
* * Neither the name of IBM nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* */
/*----------------------------------------------------------------------------- */
/* Function: */
/* This module doesn't perform any useful function. Its purpose is simply */
/* to generate invocations to the various floating point functions to test */
/* that the libraries successfuly link with an executable, and to provide */
/* a simple access point for unit test of the various functions. */
/*----------------------------------------------------------------------------- */
/*----------------------------------------------------------------------------+
| Main.
+----------------------------------------------------------------------------*/
int main()
{
typedef struct {
char name1[100];
char name2[100];
} name_s;
name_s firstnames = {"SAM", "JOE" };
name_s lastnames = firstnames;
double dx=1000;
double dy=3000;
double dz, dq;
float x=100;
float y=300;
float z, q;
float zero=0;
int sint;
unsigned int uint;
/* double precision arithmetic operations */
dz = dx+dy;
dq = dx-dy;
dz = dx/dy;
dz = dy*dy;
dq = dz/dy;
/* single precision arithmetic operations */
z = x+y;
q = x-y;
z = y*y;
q = z/y;
q = q/zero;
/* conversion functions */
x = dx; /* convert double to single */
dx = x; /* and back again */
sint = dx; /* double to signed integer */
sint = x; /* single to signed integer */
uint = dx; /* double to unsigned integer */
uint = x; /* single to unsigned integer */
dx = sint; /* signed integer to double */
x = sint; /* signed integer to single */
dx = uint; /* unsigned integer to double */
x = uint; /* unsigned integer to single */
/* double compares */
if (dx == dy)
z = q;
if (dx < dy)
z = q;
if (dx > dy)
q = z;
if (dx >= dy)
q = z;
/* single compares */
if (x == y)
z = q;
if (x < y)
z = q;
if (x > y)
q = z;
if (x >= y)
q = z;
/* mixed compares */
if (dx == y)
z = q;
if (x < dy)
z = q;
if (dx > y)
q = z;
if (x >= dy)
q = z;
return(0);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -