MCPcopy Create free account
hub / github.com/beanshell/beanshell / floatBinaryOperation

Method floatBinaryOperation

src/bsh/Primitive.java:531–591  ·  view source on GitHub ↗
(Float F1, Float F2, int kind)

Source from the content-addressed store, hash-verified

529 }
530 // returns Object covering both Long and Boolean return types
531 static Object floatBinaryOperation(Float F1, Float F2, int kind)
532 throws UtilEvalError
533 {
534 float lhs = F1.floatValue();
535 float rhs = F2.floatValue();
536
537 switch(kind)
538 {
539 // boolean
540 case LT:
541 case LTX:
542 return lhs < rhs ? Boolean.TRUE : Boolean.FALSE;
543
544 case GT:
545 case GTX:
546 return lhs > rhs ? Boolean.TRUE : Boolean.FALSE;
547
548 case EQ:
549 return lhs == rhs ? Boolean.TRUE : Boolean.FALSE;
550
551 case LE:
552 case LEX:
553 return lhs <= rhs ? Boolean.TRUE : Boolean.FALSE;
554
555 case GE:
556 case GEX:
557 return lhs >= rhs ? Boolean.TRUE : Boolean.FALSE;
558
559 case NE:
560 return lhs != rhs ? Boolean.TRUE : Boolean.FALSE;
561
562 // arithmetic
563 case PLUS:
564 return new Float(lhs + rhs);
565
566 case MINUS:
567 return new Float(lhs - rhs);
568
569 case STAR:
570 return new Float(lhs * rhs);
571
572 case SLASH:
573 return new Float(lhs / rhs);
574
575 case MOD:
576 return new Float(lhs % rhs);
577
578 // can't shift floats
579 case LSHIFT:
580 case LSHIFTX:
581 case RSIGNEDSHIFT:
582 case RSIGNEDSHIFTX:
583 case RUNSIGNEDSHIFT:
584 case RUNSIGNEDSHIFTX:
585 throw new UtilEvalError("Can't shift floats ");
586
587 default:
588 throw new InterpreterError(

Callers 1

binaryOperationImplMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected