org.jruby.util
Class Convert

java.lang.Object
  extended by org.jruby.util.Convert

public class Convert
extends java.lang.Object

Author:
Bill Dortch Primitive conversions adapted from java.lang.Integer/Long/Double (C) Sun Microsystems, Inc.

Constructor Summary
Convert()
           
 
Method Summary
static double byteArrayToDouble(byte[] bytes, int begin, int buflen, boolean strict)
          Converts a byte array containing a RubyString representation of a double value to a double.
static double byteListToDouble(org.jruby.util.ByteList bytes)
           
static double byteListToDouble(org.jruby.util.ByteList bytes, boolean strict)
          Converts a ByteList containing a RubyString representation of a double value to a double.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Convert

public Convert()
Method Detail

byteListToDouble

public static final double byteListToDouble(org.jruby.util.ByteList bytes,
                                            boolean strict)
Converts a ByteList containing a RubyString representation of a double value to a double. Equivalent to Double.parseDouble(String s), but accounts for embedded underscore characters, as permitted in Ruby strings (single underscores allowed between digits in strict mode, multiple in non-strict mode).

Parameters:
bytes - the ByteList containing the RubyString value to convert
strict - if true, strict rules (as required by Float(str)) are enforced; otherwise, the laxer rules of str.to_f are employed.
Returns:
the converted double value

byteListToDouble

public static final double byteListToDouble(org.jruby.util.ByteList bytes)

byteArrayToDouble

public static final double byteArrayToDouble(byte[] bytes,
                                             int begin,
                                             int buflen,
                                             boolean strict)
Converts a byte array containing a RubyString representation of a double value to a double. Equivalent to Double.parseDouble(String s), but accounts for embedded underscore characters, as permitted in Ruby strings (single underscores allowed between digits in strict mode, multiple in non-strict mode).

Parameters:
bytes - the array containing the RubyString value to convert
buflen - the length of the array to be used
strict - if true, strict rules (as required by Float(str)) are enforced; otherwise, the laxer rules of str.to_f are employed.
Returns:
the converted double value


Copyright © 2002-2009 JRuby Team. All Rights Reserved.