diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-05-27 16:09:39 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-05-27 16:09:39 -0300 |
| commit | 74719afc333a70dae37aa6014ee1bd50ec8aa895 (patch) | |
| tree | c523b3b79a5fb9f9bf7ef9695ba78fb78988d724 | |
| parent | 7e59a8901d063dbea4eb0693c9c2d85bda1fc5f6 (diff) | |
| download | lua-74719afc333a70dae37aa6014ee1bd50ec8aa895.tar.gz lua-74719afc333a70dae37aa6014ee1bd50ec8aa895.tar.bz2 lua-74719afc333a70dae37aa6014ee1bd50ec8aa895.zip | |
new functions "frexp" and "ldexp"
| -rw-r--r-- | lmathlib.c | 16 | ||||
| -rw-r--r-- | manual.tex | 10 |
2 files changed, 20 insertions, 6 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lmathlib.c,v 1.7 1997/12/09 13:35:19 roberto Exp roberto $ | 2 | ** $Id: lmathlib.c,v 1.8 1997/12/26 18:36:31 roberto Exp roberto $ |
| 3 | ** Lua standard mathematical library | 3 | ** Lua standard mathematical library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -115,6 +115,16 @@ static void math_rad (void) | |||
| 115 | lua_pushnumber(luaL_check_number(1)*(PI/180.0)); | 115 | lua_pushnumber(luaL_check_number(1)*(PI/180.0)); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | static void math_frexp (void) { | ||
| 119 | int e; | ||
| 120 | lua_pushnumber(frexp(luaL_check_number(1), &e)); | ||
| 121 | lua_pushnumber(e); | ||
| 122 | } | ||
| 123 | |||
| 124 | static void math_ldexp (void) { | ||
| 125 | lua_pushnumber(ldexp(luaL_check_number(1), luaL_check_number(2))); | ||
| 126 | } | ||
| 127 | |||
| 118 | 128 | ||
| 119 | 129 | ||
| 120 | static void math_min (void) | 130 | static void math_min (void) |
| @@ -170,10 +180,12 @@ static struct luaL_reg mathlib[] = { | |||
| 170 | {"asin", math_asin}, | 180 | {"asin", math_asin}, |
| 171 | {"acos", math_acos}, | 181 | {"acos", math_acos}, |
| 172 | {"atan", math_atan}, | 182 | {"atan", math_atan}, |
| 173 | {"atan2", math_atan2}, | 183 | {"atan2", math_atan2}, |
| 174 | {"ceil", math_ceil}, | 184 | {"ceil", math_ceil}, |
| 175 | {"floor", math_floor}, | 185 | {"floor", math_floor}, |
| 176 | {"mod", math_mod}, | 186 | {"mod", math_mod}, |
| 187 | {"frexp", math_frexp}, | ||
| 188 | {"ldexp", math_ldexp}, | ||
| 177 | {"sqrt", math_sqrt}, | 189 | {"sqrt", math_sqrt}, |
| 178 | {"min", math_min}, | 190 | {"min", math_min}, |
| 179 | {"max", math_max}, | 191 | {"max", math_max}, |
| @@ -1,4 +1,4 @@ | |||
| 1 | % $Id: manual.tex,v 1.9 1998/05/18 22:26:03 roberto Exp roberto $ | 1 | % $Id: manual.tex,v 1.10 1998/05/20 22:21:35 roberto Exp roberto $ |
| 2 | 2 | ||
| 3 | \documentstyle[fullpage,11pt,bnf]{article} | 3 | \documentstyle[fullpage,11pt,bnf]{article} |
| 4 | 4 | ||
| @@ -38,7 +38,7 @@ Waldemar Celes | |||
| 38 | \tecgraf\ --- Computer Science Department --- PUC-Rio | 38 | \tecgraf\ --- Computer Science Department --- PUC-Rio |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | \date{\small \verb$Date: 1998/05/18 22:26:03 $} | 41 | \date{\small \verb$Date: 1998/05/20 22:21:35 $} |
| 42 | 42 | ||
| 43 | \maketitle | 43 | \maketitle |
| 44 | 44 | ||
| @@ -2398,10 +2398,12 @@ The library provides the following functions: | |||
| 2398 | \Deffunc{atan2}\Deffunc{ceil}\Deffunc{cos}\Deffunc{floor} | 2398 | \Deffunc{atan2}\Deffunc{ceil}\Deffunc{cos}\Deffunc{floor} |
| 2399 | \Deffunc{log}\Deffunc{log10}\Deffunc{max}\Deffunc{min} | 2399 | \Deffunc{log}\Deffunc{log10}\Deffunc{max}\Deffunc{min} |
| 2400 | \Deffunc{mod}\Deffunc{sin}\Deffunc{sqrt}\Deffunc{tan} | 2400 | \Deffunc{mod}\Deffunc{sin}\Deffunc{sqrt}\Deffunc{tan} |
| 2401 | \Deffunc{frexp}\Deffunc{ldexp} | ||
| 2401 | \Deffunc{random}\Deffunc{randomseed} | 2402 | \Deffunc{random}\Deffunc{randomseed} |
| 2402 | \begin{verbatim} | 2403 | \begin{verbatim} |
| 2403 | abs acos asin atan atan2 ceil cos deg floor log log10 | 2404 | abs acos asin atan atan2 ceil cos deg floor log log10 |
| 2404 | max min mod rad sin sqrt tan random randomseed | 2405 | max min mod rad sin sqrt tan frexp ldexp |
| 2406 | random randomseed | ||
| 2405 | \end{verbatim} | 2407 | \end{verbatim} |
| 2406 | plus a global variable \IndexVerb{PI}. | 2408 | plus a global variable \IndexVerb{PI}. |
| 2407 | Most of them | 2409 | Most of them |
