www.pudn.com > GA_Toolbar.rar > CALCBITS.M, change:1997-04-07,size:479b


function [bits]=calcbits(bounds,precision) 
% function [bits]=calcbits(bounds,precision) 
% Determine the number of bits to represent a float number to the precision 
% provided. 
% 
% bits      - the number of bits required per variable 
% bounds    - the bounds on the variables 
% precision - the least difference to distinguish two numbers 
bits=ceil(log2((bounds(:,2)-bounds(:,1))' ./ precision)); 
% bits=ceil(log( (bounds(:,2)-bounds(:,1))' .* 10.^precision+1) ./ log(2));