001    /**
002     * Implements the CFML Function bitmaskread
003     */
004    package railo.runtime.functions.math;
005    
006    import railo.runtime.PageContext;
007    import railo.runtime.exp.FunctionException;
008    import railo.runtime.ext.function.Function;
009    
010    public final class BitMaskRead implements Function {
011            
012            public static double call(PageContext pc , double dnumber, double dstart, double dlength) throws FunctionException {
013    
014                    int number=(int) dnumber,start=(int) dstart,length=(int) dlength;
015                    
016                    if(start > 31 || start < 0)
017                            throw new FunctionException(pc,"bitMaskRead",2,"start","must be beetween 0 and 31 now "+start);
018                    if(length > 31 || length < 0)
019                            throw new FunctionException(pc,"bitMaskRead",3,"length","must be beetween 0 and 31 now "+length);
020                    
021    
022            return number >> start & (1 << length) - 1;
023            }
024    }