Package java.lang

Examples of java.lang.Double


        String answer;
      if ("1+2".equals(question)) {
        answer = "3";
      } else {
            Random r = new Random(new Date().getTime());
            Double d = new Double((r.nextDouble() * 20) - 1);
            answer = new String(answers[d.intValue()]);
      }
    System.out.println("EightBall answer: " + answer);
    return answer;
    }
View Full Code Here


    static final boolean USE_POLAR_RANDOM = true;
    static final Hashtable NEXT_GAUSSIANS = new Hashtable();

    static double polar_random( uniform PRNG )
    {
        Double d = (Double) NEXT_GAUSSIANS.remove(PRNG);
        if (d != null) return d.doubleValue();

        double v1, v2, s;
        do {
            v1 = 2 * PRNG.random() - 1; // between -1 and 1
            v2 = 2 * PRNG.random() - 1; // between -1 and 1
            s = v1 * v1 + v2 * v2;
        } while (s >= 1 || s == 0);
        double multiplier = Math.sqrt(-2 * Math.log(s)/s);
        Double nextNextGaussian = new Double(v2 * multiplier);
        NEXT_GAUSSIANS.put(PRNG, nextNextGaussian);
        return v1 * multiplier;
    }
View Full Code Here

  }


  private void reset()
  {
    Double rate = (Double)rates_.get(c2_);
    Date date = new Date();
   
    rate_ = rate.doubleValue();
    dealData_.setSpotRate(rateValidator_.formatRate(rate_));
    rateValidator_.set(rate_);
    dateValidator_.reset();
    dealData_.setValueDate(date);
    dealData_.setTradingDate(date);
View Full Code Here

   NTIMES=10;
   OFFSET=0;
   HLINE= "-------------------------------------------------------------";
   precision = 8; // java uses 8bytes per DOUBLE PRECISION word

   tmp=  new Double(0);
   FLT_MAX =tmp.longBitsToDouble(0x7fefffffffffffffL);


   a  = new double[N+OFFSET];
   b  = new double[N+OFFSET];
View Full Code Here

   NTIMES=10;
   OFFSET=0;
   HLINE= "-------------------------------------------------------------";
   precision = 8; // java uses 8bytes per DOUBLE PRECISION word

   tmp=  new Double(0);
   FLT_MAX =tmp.longBitsToDouble(0x7fefffffffffffffL);


   a  = new double[N+OFFSET];
   b  = new double[N+OFFSET];
View Full Code Here

      stmt.setDate(pos, Date.valueOf(p.getValue()));
    }

    if (type.equalsIgnoreCase("double"))
    {
      Double d = new Double(p.getValue());
      stmt.setDouble(pos, d.doubleValue() );
    }

    if (type.equalsIgnoreCase("float"))
    {
      Float f = new Float(p.getValue());
View Full Code Here


    private static Double evaluateExpression( Operator o, Double f1, Double f2)
    {
        String op   = o.getOperator();
        Double res   = null;

        if     ( "+".equals(op) )
            res = new Double( f1.doubleValue() + f2.doubleValue() );
        else if  ( "-".equals(op) )
            res = new Double( f1.doubleValue() - f2.doubleValue() );
        else if  ( "*".equals(op) )
            res = new Double( f1.doubleValue() * f2.doubleValue() );
        else if  ( "/".equals(op) )
            res = new Double( f1.doubleValue() / f2.doubleValue() );
        else if  ( "%".equals(op) )
            res = new Double( f1.doubleValue() % f2.doubleValue() );
        else if  ( "|".equals(op) )
            res =   new Double(Double.longBitsToDouble( Double.doubleToLongBits( f1.doubleValue()) | Double.doubleToLongBits( f2.doubleValue() ) ));
        else if  ( "&".equals(op) )
            res =  new Double( Double.longBitsToDouble( Double.doubleToLongBits( f1.doubleValue() ) & Double.doubleToLongBits( f2.doubleValue() ) ));
        else if  ( "^".equals(op) )
            res =  new Double( Double.longBitsToDouble( Double.doubleToLongBits( f1.doubleValue() ) ^ Double.doubleToLongBits( f2.doubleValue() ) ));
        else if  ( "<<".equals(op) )
            res =  new Double( Double.longBitsToDouble( Double.doubleToLongBits( f1.doubleValue() ) << Double.doubleToLongBits( f2.doubleValue() ) ));
        else if  ( ">>".equals(op) )
            res =  new Double( Double.longBitsToDouble( Double.doubleToLongBits( f1.doubleValue() ) >> Double.doubleToLongBits( f2.doubleValue() ) ));

        return res;
    }
View Full Code Here

    private Double getDouble(String s)
    {
        if ( s == null )
            return null;

        Double res = null;
        try
        {
            res = new Double(Double.parseDouble(s));
        }
        catch(Exception e)
        {
            return getVariable(s);
        }
View Full Code Here

      stmt.setDate(pos, Date.valueOf(p.getValue()));
    }

    if (type.equalsIgnoreCase("double"))
    {
      Double d = new Double(p.getValue());
      stmt.setDouble(pos, d.doubleValue() );
    }

    if (type.equalsIgnoreCase("float"))
    {
      Float f = new Float(p.getValue());
View Full Code Here

        String tripleCurrencyStr = "\u00A4\u00A4\u00A4";

        for (int i=0; i<DATA.length; ++i) {
            String locale = DATA[i][0];
            String pat = DATA[i][1];
            Double numberToBeFormat = new Double(DATA[i][2]);
            DecimalFormatSymbols sym = new DecimalFormatSymbols(new ULocale(locale));
            for (int j=1; j<=3; ++j) {
                // j represents the number of currency sign in the pattern.
                if (j == 2) {
                    pat = Utility.replaceAll(pat, "\u00A4", doubleCurrencyStr);
                } else if (j == 3) {
                    pat = Utility.replaceAll(pat, "\u00A4\u00A4", tripleCurrencyStr);
                }
                DecimalFormat fmt = new DecimalFormat(pat, sym);
                String s = ((NumberFormat) fmt).format(numberToBeFormat);
                // DATA[i][3] is the currency format result using a
                // single currency sign.
                // DATA[i][4] is the currency format result using
                // double currency sign.
                // DATA[i][5] is the currency format result using
                // triple currency sign.
                // DATA[i][j+2] is the currency format result using
                // 'j' number of currency sign.
                String currencyFormatResult = DATA[i][2+j];
                if (!s.equals(currencyFormatResult)) {
                    errln("FAIL format: Expected " + currencyFormatResult);
                }
                try {
                    // mix style parsing
                    for (int k=3; k<=5; ++k) {
                      // DATA[i][3] is the currency format result using a
                      // single currency sign.
                      // DATA[i][4] is the currency format result using
                      // double currency sign.
                      // DATA[i][5] is the currency format result using
                      // triple currency sign.
                      String oneCurrencyFormat = DATA[i][k];
                      if (fmt.parse(oneCurrencyFormat).doubleValue() !=
                          numberToBeFormat.doubleValue()) {
                        errln("FAILED parse " + oneCurrencyFormat);
                      }
                    }
                } catch (ParseException e) {
                    errln("FAILED, DecimalFormat parse currency: " + e.toString());
View Full Code Here

TOP

Related Classes of java.lang.Double

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.