~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/elem/log2.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
function [f,e]=log2(x)
2
 
[lhs,rhs]=argn(0)
3
 
if lhs==1 then
 
2
if argn(1)==1 then
4
3
  f=log(x)/log(2)
5
4
else
6
 
  k = find(x<>0);
7
 
  e(k) = ceil(log(abs(x(k)))/log(2));
8
 
  f(k) = x(k)./(2^e(k));
9
 
  k = find(f>=1);
10
 
  f(k) = 0.5
11
 
  e(k) = e(k)+1
 
5
  [f,e]=frexp(x)
12
6
end
13
 
 
 
7
endfunction