Package gnu.math

Examples of gnu.math.BigSquareRoot


                    RatNum value = ((Number)IokeObject.data(on)).value;
                    if(value instanceof IntFraction) {
                        IntNum num = value.numerator();
                        IntNum den = value.denominator();
                        BigDecimal nums = new BigSquareRoot().get(num.asBigDecimal());
                        BigDecimal dens = new BigSquareRoot().get(den.asBigDecimal());
                        try {
                            num = IntNum.valueOf(nums.toBigIntegerExact().toString());
                            den = IntNum.valueOf(dens.toBigIntegerExact().toString());
                            return context.runtime.newNumber(new IntFraction(num, den));
                        } catch(ArithmeticException e) {
                            // Ignore and fall through
                        }
                    }
                   
                    if(RatNum.compare(value, IntNum.zero()) < 1) {
                        final IokeObject condition = IokeObject.as(IokeObject.getCellChain(context.runtime.condition,
                                                                                           message,
                                                                                           context,
                                                                                           "Error",
                                                                                           "Arithmetic"), context).mimic(message, context);
                        condition.setCell("message", message);
                        condition.setCell("context", context);
                        condition.setCell("receiver", on);

                        context.runtime.errorCondition(condition);
                    }

                    return context.runtime.newDecimal(new BigSquareRoot().get(value.asBigDecimal()));
                }
            }));

        number.registerMethod(runtime.newNativeMethod("returns true if the left hand side number is equal to the right hand side number.", new TypeCheckingNativeMethod("==") {
                private final TypeCheckingArgumentsDefinition ARGUMENTS = TypeCheckingArgumentsDefinition
View Full Code Here


                        condition.setCell("receiver", on);

                        context.runtime.errorCondition(condition);
                    }

                    return context.runtime.newDecimal(new BigSquareRoot().get(value));
                }
            }));

        obj.registerMethod(runtime.newNativeMethod("returns true if the left hand side decimal is equal to the right hand side decimal.", new TypeCheckingNativeMethod("==") {
                private final TypeCheckingArgumentsDefinition ARGUMENTS = TypeCheckingArgumentsDefinition
View Full Code Here

TOP

Related Classes of gnu.math.BigSquareRoot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.