php.runtime.Memory.toNumeric()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中php.runtime.Memory.toNumeric()方法的一些代码示例,展示了Memory.toNumeric()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Memory.toNumeric()方法的具体详情如下:
包路径:php.runtime.Memory
类名称:Memory
方法名:toNumeric

Memory.toNumeric介绍

暂无

代码示例

代码示例来源:origin: jphp-group/jphp

@Signature({
    @Arg("num1"), @Arg("num2")
})
public static Memory compare(Environment env, Memory... args) {
  return LongMemory.valueOf(args[0].toNumeric().compareTo(args[1].toNumeric()));
}

代码示例来源:origin: jphp-group/jphp

@Override
public Memory mul(Memory memory) {
  switch (memory.type){
    case INT:
    case DOUBLE: return memory;
    case REFERENCE: return mul(memory.toValue());
    default: return memory.toNumeric();
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public Memory plus(Memory memory) {
  switch (memory.type){
    case INT:
    case DOUBLE: return memory;
    case REFERENCE: return plus(memory.toValue());
    default: return memory.toNumeric();
  }
}

代码示例来源:origin: jphp-group/jphp

public Memory pow(boolean value) {
  Memory real = toNumeric();
  if (real instanceof LongMemory) {
    return value ? real.toImmutable() : Memory.CONST_INT_1;
  }
  return value ? real.toImmutable() : Memory.CONST_DOUBLE_1;
}
public Memory pow(String value) { return pow(StringMemory.toNumeric(value)); }

代码示例来源:origin: jphp-group/jphp

public Memory pow(long value) {
  Memory real = toNumeric();
  if (real instanceof LongMemory) {
    double result = Math.pow(real.toLong(), value);
    if (result > Long.MAX_VALUE) {
      return new DoubleMemory(result);
    }
    return new LongMemory((long) result);
  }
  return new DoubleMemory(Math.pow(real.toDouble(), value));
}
public Memory pow(double value) { return new DoubleMemory(Math.pow(toDouble(), value)); }

代码示例来源:origin: jphp-group/jphp

@Override
public Memory pow(Memory memory) {
  switch (memory.type){
    case INT: return new DoubleMemory(Math.pow(value, ((LongMemory)memory).value));
    case DOUBLE: return new DoubleMemory(Math.pow(value, ((LongMemory)memory).value));
    case REFERENCE: return mul(memory.toImmutable());
    default: return pow(memory.toNumeric());
  }
}

代码示例来源:origin: jphp-group/jphp

@Immutable
public static Memory abs(Memory value) {
  switch (value.type){
    case DOUBLE: return new DoubleMemory(Math.abs(value.toDouble()));
    case STRING: return abs(value.toNumeric());
    default: return LongMemory.valueOf(Math.abs(value.toLong()));
  }
}

代码示例来源:origin: jphp-group/jphp

@Immutable
public static double sin(Memory memory){
  switch (memory.type){
    case DOUBLE: return Math.sin(memory.toDouble());
    case STRING: return sin(memory.toNumeric());
    default:
      return _sin(memory.toLong());
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public boolean equal(Memory memory) {
  switch (memory.type){
    case INT: return ((LongMemory)memory).value == value;
    case DOUBLE: return ((DoubleMemory)memory).value == value;
    case STRING: return equal(memory.toNumeric());
    case REFERENCE: return equal(memory.toValue());
    default:
      return value == memory.toLong();
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public Memory div(Memory memory) {
  switch (memory.type){
    case DOUBLE: return new DoubleMemory(1 / ((DoubleMemory)memory).value);
    case REFERENCE: return div(memory.toValue());
    default:
      return CONST_INT_1.div(memory.toNumeric());
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public boolean notEqual(Memory memory) {
  switch (memory.type){
    case INT: return ((LongMemory)memory).value != value;
    case DOUBLE: return ((DoubleMemory)memory).value != value;
    case STRING: return notEqual(memory.toNumeric());
    case REFERENCE: return notEqual(memory.toValue());
    default:
      return value != toLong();
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public Memory mul(Memory memory) {
  switch (memory.type){
    case INT: return LongMemory.valueOf(value * ((LongMemory) memory).value);
    case DOUBLE: return new DoubleMemory(value * ((DoubleMemory)memory).value);
    case REFERENCE: return mul(memory.toValue());
    default: return mul(memory.toNumeric());
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public Memory minus(Memory memory) {
  switch (memory.type){
    case INT: return new LongMemory(-((LongMemory)memory).value);
    case DOUBLE: return new DoubleMemory(-((DoubleMemory)memory).value);
    case REFERENCE: return minus(memory.toValue());
    default: return minus(memory.toNumeric());
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public Memory minus(Memory memory) {
  switch (memory.type){
    case INT: return new DoubleMemory(value - ((LongMemory)memory).value);
    case DOUBLE: return new DoubleMemory(value - ((DoubleMemory)memory).value);
    case REFERENCE: return minus(memory.toValue());
    default: return minus(memory.toNumeric());
  }
}

代码示例来源:origin: jphp-group/jphp

@Override
public Memory plus(Memory memory) {
  switch (memory.type){
    case INT: return LongMemory.valueOf(1 + ((LongMemory) memory).value);
    case DOUBLE: return new DoubleMemory(1 + ((DoubleMemory)memory).value);
    case REFERENCE: return plus(memory.toValue());
    default: return memory.toNumeric().plus(CONST_INT_1);
  }
}

代码示例来源:origin: jphp-group/jphp

public static Memory mul(long o1, Memory value) {
  switch (value.type){
    case INT: return LongMemory.valueOf(o1 * value.toLong());
    case DOUBLE: return DoubleMemory.valueOf(o1 * value.toDouble());
  }
  return mul(o1, value.toNumeric());
}
public static Memory mul(double o1, Memory value) { return DoubleMemory.valueOf(o1 * value.toDouble()); }

代码示例来源:origin: jphp-group/jphp

@Test
public void testToNumeric(){
  Assert.assertTrue(Memory.TRUE.toNumeric() instanceof LongMemory);
  Assert.assertEquals(1, Memory.TRUE.toNumeric().toLong());
}

代码示例来源:origin: jphp-group/jphp

public static Memory plus(long o1, Memory value) {
  switch (value.type){
    case INT: return LongMemory.valueOf(o1 + value.toLong());
    case DOUBLE: return DoubleMemory.valueOf(o1 + value.toDouble());
  }
  return plus(o1, value.toNumeric());
}
public static Memory plus(double o1, Memory value) { return DoubleMemory.valueOf(o1 + value.toDouble()); }

代码示例来源:origin: jphp-group/jphp

public static Memory minus(long o1, Memory value) {
  switch (value.type){
    case INT: return LongMemory.valueOf(o1 - value.toLong());
    case DOUBLE: return DoubleMemory.valueOf(o1 - value.toDouble());
  }
  return minus(o1, value.toNumeric());
}
public static Memory minus(double o1, Memory value) { return DoubleMemory.valueOf(o1 - value.toDouble()); }

代码示例来源:origin: jphp-group/jphp

@Override
public Memory minus(Memory memory) {
  switch (memory.type){
    case INT: return LongMemory.valueOf(1 - ((LongMemory)memory).value);
    case DOUBLE: return new DoubleMemory(1 - ((DoubleMemory)memory).value);
    case REFERENCE: return minus(memory.toValue());
    case BOOL: return LongMemory.valueOf(1 - memory.toLong());
    default: return CONST_INT_1.minus(memory.toNumeric());
  }
}

相关文章