A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2FMath%2FSin_ASin</id>
		<title>C/Math/Sin ASin - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2FMath%2FSin_ASin"/>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C/Math/Sin_ASin&amp;action=history"/>
		<updated>2026-04-17T22:40:39Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C/Math/Sin_ASin&amp;diff=162&amp;oldid=prev</id>
		<title> в 14:20, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C/Math/Sin_ASin&amp;diff=162&amp;oldid=prev"/>
				<updated>2010-05-25T14:20:56Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:20, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C/Math/Sin_ASin&amp;diff=163&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C/Math/Sin_ASin&amp;diff=163&amp;oldid=prev"/>
				<updated>2010-05-25T10:22:22Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Calculate arcsine: how to use asin==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#define PI 3.14159265&lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
  double v, result;&lt;br /&gt;
  v = 0.5;&lt;br /&gt;
  &lt;br /&gt;
  result = asin ( v ) * 180 / PI;&lt;br /&gt;
  printf (&amp;quot;Arcsine of %lf is %lf degrees\n&amp;quot;, v, result );&lt;br /&gt;
  &lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Calculate hyperbolic sine: how to use sinh==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#define PI 3.14159265&lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
  double param, result;&lt;br /&gt;
  param = 60;&lt;br /&gt;
  result = cosh ( param * PI / 180 );&lt;br /&gt;
  printf (&amp;quot;Hyperbolic sine %lf degrees = %lf\n&amp;quot;, param, result );&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Calculate sine: sin==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#define PI 3.14159265&lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
  double param, result;&lt;br /&gt;
  param = 60;&lt;br /&gt;
  result = sin (param * PI / 180);&lt;br /&gt;
  printf (&amp;quot;Sine of %lf degrees is %lf\n&amp;quot;, param, result );&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==compute sine using very simple floating arithmetic==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Practical C Programming, Third Edition&lt;br /&gt;
By Steve Oualline&lt;br /&gt;
Third Edition August 1997 &lt;br /&gt;
ISBN: 1-56592-306-5&lt;br /&gt;
Publisher: O&amp;quot;Reilly&lt;br /&gt;
*/&lt;br /&gt;
/* Usage:                                               *&lt;br /&gt;
 *      sine &amp;lt;value&amp;gt;                                    *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 *      &amp;lt;value&amp;gt; is an angle in radians                  *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Format used in f.fffe+X                              *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * f.fff is a 4 digit fraction                          *&lt;br /&gt;
 *      + is a sign (+ or -)                            *&lt;br /&gt;
 *      X is a single digit exponent                    *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * sine(x) = x  - x**3 + x**5 - x**7                    *&lt;br /&gt;
 *               -----   ----   ---- . . . .            *&lt;br /&gt;
 *                 3!     5!     7!                     *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Warning: This program is intended to show some of    *&lt;br /&gt;
 *      problems with floating point.  It not intended  *&lt;br /&gt;
 *      to be used to produce exact values for the      *&lt;br /&gt;
 *      sin function.                                   *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Note: Even though we specify only one-digit for the  *&lt;br /&gt;
 *       exponent, two are used for some calculations.  *&lt;br /&gt;
 *       This is due to the fact that printf has no     *&lt;br /&gt;
 *       format for a single digit exponent.            *&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;  &lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * float_2_ascii -- turn a floating-point string        *&lt;br /&gt;
 *      into ascii.                                     *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Parameters                                           *&lt;br /&gt;
 *      number -- number to turn into ascii             *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Returns                                              *&lt;br /&gt;
 *      Pointer to the string containing the number     *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Warning: Uses static storage, so later calls         *&lt;br /&gt;
 *              overwrite earlier entries               *&lt;br /&gt;
 */&lt;br /&gt;
static char *float_2_ascii(float number)&lt;br /&gt;
{&lt;br /&gt;
    static char result[10]; /*place to put the number */&lt;br /&gt;
    sprintf(result,&amp;quot;%8.3E&amp;quot;, number);&lt;br /&gt;
    return (result);&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * fix_float -- turn high precision numbers into        *&lt;br /&gt;
 *              low precision numbers to simulate a     *&lt;br /&gt;
 *              very dumb floating-point structure.     *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Parameters                                           *&lt;br /&gt;
 *      number -- number to take care of                *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Returns                                              *&lt;br /&gt;
 *      number accurate to 5 places only                *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Note: This works by changing a number into ascii and *&lt;br /&gt;
 *       back.  Very slow, but it works.                *&lt;br /&gt;
 */&lt;br /&gt;
float fix_float(float number)&lt;br /&gt;
{&lt;br /&gt;
    float   result; /* result of the conversion */&lt;br /&gt;
    char    ascii[10];      /* ascii version of number */&lt;br /&gt;
    sprintf(ascii,&amp;quot;%8.4e&amp;quot;, number);&lt;br /&gt;
    sscanf(ascii, &amp;quot;%e&amp;quot;, &amp;amp;result);&lt;br /&gt;
    return (result);&lt;br /&gt;
}&lt;br /&gt;
/*&lt;br /&gt;
 * factorial -- compute the factorial of a number.      *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Parameters                                           *&lt;br /&gt;
 *      number -- number to use for factorial           *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Returns                                              *&lt;br /&gt;
 *      factorial(number) or number!                    *&lt;br /&gt;
 *                                                      *&lt;br /&gt;
 * Note: Even though this is a floating-point routine,  *&lt;br /&gt;
 *       using numbers that are not whole numbers       *&lt;br /&gt;
 *       does not make sense.                           *&lt;br /&gt;
 */&lt;br /&gt;
float factorial(float number)&lt;br /&gt;
{&lt;br /&gt;
    if (number &amp;lt;= 1.0)&lt;br /&gt;
  return (number);&lt;br /&gt;
    else&lt;br /&gt;
  return (number *factorial(number - 1.0));&lt;br /&gt;
}&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
    float   total;  /* total of series so far */&lt;br /&gt;
    float   new_total;/* newer version of total */&lt;br /&gt;
    float   term_top;/* top part of term */&lt;br /&gt;
    float   term_bottom;/* bottom of current term */&lt;br /&gt;
    float   term;   /* current term */&lt;br /&gt;
    float   exp;    /* exponent of current term */&lt;br /&gt;
    float   sign;   /* +1 or -1 (changes on each term) */&lt;br /&gt;
    float   value;  /* value of the argument to sin */&lt;br /&gt;
    int     index;  /* index for counting terms */&lt;br /&gt;
    if (argc != 2) {&lt;br /&gt;
  fprintf(stderr,&amp;quot;Usage is:\n&amp;quot;);&lt;br /&gt;
  fprintf(stderr,&amp;quot;  sine &amp;lt;value&amp;gt;\n&amp;quot;);&lt;br /&gt;
  exit (8);&lt;br /&gt;
    }&lt;br /&gt;
    value = fix_float(atof(&amp;amp;argv[1][0]));&lt;br /&gt;
    total = 0.0;&lt;br /&gt;
    exp = 1.0;&lt;br /&gt;
    sign = 1.0;&lt;br /&gt;
    for (index = 0; /* take care of below */ ; ++index) {&lt;br /&gt;
  term_top = fix_float(pow(value, exp));&lt;br /&gt;
  term_bottom = fix_float(factorial(exp));&lt;br /&gt;
  term = fix_float(term_top / term_bottom);&lt;br /&gt;
  printf(&amp;quot;x**%d     %s\n&amp;quot;, (int)exp, &lt;br /&gt;
      float_2_ascii(term_top));&lt;br /&gt;
  printf(&amp;quot;%d!       %s\n&amp;quot;, (int)exp, &lt;br /&gt;
      float_2_ascii(term_bottom));&lt;br /&gt;
  printf(&amp;quot;x**%d/%d! %s\n&amp;quot;, (int)exp, (int)exp,&lt;br /&gt;
    float_2_ascii(term));&lt;br /&gt;
  printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
  new_total = fix_float(total + sign * term);&lt;br /&gt;
  if (new_total == total)&lt;br /&gt;
      break;&lt;br /&gt;
  total = new_total;&lt;br /&gt;
  sign = -sign;&lt;br /&gt;
  exp = exp + 2.0;&lt;br /&gt;
  printf(&amp;quot;  total   %s\n&amp;quot;, float_2_ascii(total));&lt;br /&gt;
  printf(&amp;quot;\n&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    printf(&amp;quot;%d term computed\n&amp;quot;, index+1);&lt;br /&gt;
    printf(&amp;quot;sin(%s)=\n&amp;quot;, float_2_ascii(value));&lt;br /&gt;
    printf(&amp;quot;  %s\n&amp;quot;, float_2_ascii(total));&lt;br /&gt;
    printf(&amp;quot;Actual sin(%G)=%G\n&amp;quot;,&lt;br /&gt;
      atof(&amp;amp;argv[1][0]), sin(atof(&amp;amp;argv[1][0])));&lt;br /&gt;
    return (0);&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==copy one file to another==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Practical C Programming, Third Edition&lt;br /&gt;
By Steve Oualline&lt;br /&gt;
Third Edition August 1997 &lt;br /&gt;
ISBN: 1-56592-306-5&lt;br /&gt;
Publisher: O&amp;quot;Reilly&lt;br /&gt;
*/&lt;br /&gt;
/* Usage                                *&lt;br /&gt;
 *      copy &amp;lt;from&amp;gt; &amp;lt;to&amp;gt;                *&lt;br /&gt;
 *                                      *&lt;br /&gt;
 * &amp;lt;from&amp;gt; -- the file to copy from      *&lt;br /&gt;
 * &amp;lt;to&amp;gt;   -- the file to copy into      *&lt;br /&gt;
 ****************************************/&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#ifndef __MSDOS__       /* if we are not MS-DOS */&lt;br /&gt;
#define __UNIX__        /* then we are UNIX */&lt;br /&gt;
#endif /* __MSDOS__ */&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;     &lt;br /&gt;
#ifdef __UNIX__&lt;br /&gt;
#include &amp;lt;sys/types.h&amp;gt;  /* file defines for UNIX filesystem */&lt;br /&gt;
#include &amp;lt;sys/stat.h&amp;gt;&lt;br /&gt;
#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#endif /* __UNIX__ */&lt;br /&gt;
#ifdef __MSDOS__&lt;br /&gt;
#include &amp;lt;fcntl.h&amp;gt;     /* file defines for DOS filesystem */&lt;br /&gt;
#include &amp;lt;sys\stat.h&amp;gt;&lt;br /&gt;
#include &amp;lt;io.h&amp;gt;&lt;br /&gt;
#endif __MSDOS__&lt;br /&gt;
#ifndef O_BINARY&lt;br /&gt;
#define O_BINARY 0  /* Define the flag if not defined yet */&lt;br /&gt;
#endif /* O_BINARY */&lt;br /&gt;
#define BUFFER_SIZE (16 * 1024) /* use 16K buffers */&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
    char  buffer[BUFFER_SIZE];  /* buffer for data */&lt;br /&gt;
    int   in_file;              /* input file descriptor */&lt;br /&gt;
    int   out_file;             /* output file descriptor */&lt;br /&gt;
    int   read_size;            /* number of bytes on last read */&lt;br /&gt;
    if (argc != 3) {&lt;br /&gt;
        fprintf(stderr, &amp;quot;Error:Wrong number of arguments\n&amp;quot;);&lt;br /&gt;
        fprintf(stderr, &amp;quot;Usage is: copy &amp;lt;from&amp;gt; &amp;lt;to&amp;gt;\n&amp;quot;);&lt;br /&gt;
        exit(8);&lt;br /&gt;
    }&lt;br /&gt;
    in_file = open(argv[1], O_RDONLY|O_BINARY);&lt;br /&gt;
    if (in_file &amp;lt; 0) {&lt;br /&gt;
        fprintf(&amp;quot;Error:Unable to open %s\n&amp;quot;, argv[1]);&lt;br /&gt;
        exit(8);&lt;br /&gt;
    }&lt;br /&gt;
    out_file = open(argv[2], O_WRONLY|O_TRUNC|O_CREAT|O_BINARY, 0666);&lt;br /&gt;
    if (out_file &amp;lt; 0) {&lt;br /&gt;
        fprintf(&amp;quot;Error:Unable to open %s\n&amp;quot;, argv[2]);&lt;br /&gt;
        exit(8);&lt;br /&gt;
    }&lt;br /&gt;
    while (1) {&lt;br /&gt;
        read_size = read(in_file, buffer, sizeof(buffer));&lt;br /&gt;
        if (read_size == 0)&lt;br /&gt;
            break;              /* end of file */&lt;br /&gt;
        if (read_size &amp;lt; 0) {&lt;br /&gt;
            fprintf(stderr, &amp;quot;Error:Read error\n&amp;quot;);&lt;br /&gt;
            exit(8);&lt;br /&gt;
        }&lt;br /&gt;
        write(out_file, buffer, (unsigned int) read_size);&lt;br /&gt;
    }&lt;br /&gt;
    close(in_file);&lt;br /&gt;
    close(out_file);&lt;br /&gt;
    return (0);&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How to use asin==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  double val = -1.0;&lt;br /&gt;
  do {&lt;br /&gt;
    printf(&amp;quot;Arc sine of %f is %f.\n&amp;quot;, val, asin(val));&lt;br /&gt;
    val += 0.1;&lt;br /&gt;
  } while(val&amp;lt;=1.0);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==How to use sin==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  double val = -1.0;&lt;br /&gt;
  do {&lt;br /&gt;
    printf(&amp;quot;Sine of %f is %f.\n&amp;quot;, val, sin(val));&lt;br /&gt;
    val += 0.1;&lt;br /&gt;
  } while(val&amp;lt;=1.0);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Hyperbolic sine: how to use sinh==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;math.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
  double val = -1.0;&lt;br /&gt;
  do {&lt;br /&gt;
    printf(&amp;quot;Hyperbolic sine of %f is %f.\n&amp;quot;, val, sinh(val));&lt;br /&gt;
    val += 0.1;&lt;br /&gt;
  } while(val&amp;lt;=1.0);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>