floating point */
| 2647 | |
| 2648 | /* floating point */ |
| 2649 | bv_variable lib_common_frexp(bv_program* prog, u8 count, bv_variable* args) |
| 2650 | { |
| 2651 | /* frexp(genType, out genIType), frexp(float, out int), also for genDType */ |
| 2652 | if (count == 2) { |
| 2653 | if (args[0].type == bv_type_object) { |
| 2654 | bv_object* vec = bv_variable_get_object(args[0]); |
| 2655 | |
| 2656 | // using: genType, float, genDType, double |
| 2657 | glm::vec4 x = sd::AsVector<4, float>(args[0]); |
| 2658 | glm::vec4 signData(0.0f); |
| 2659 | glm::ivec4 expValData(0.0f); |
| 2660 | |
| 2661 | signData = glm::frexp(x, expValData); |
| 2662 | |
| 2663 | // param out value |
| 2664 | bv_variable* outPtr = bv_variable_get_pointer(args[1]); |
| 2665 | bv_object* outObj = bv_variable_get_object(*outPtr); |
| 2666 | for (u16 i = 0; i < outObj->type->props.name_count; i++) |
| 2667 | outObj->prop[i] = bv_variable_create_int(expValData[i]); |
| 2668 | |
| 2669 | // return value |
| 2670 | bv_variable ret = Common::create_vec(prog, bv_type_float, vec->type->props.name_count); |
| 2671 | bv_object* retObj = bv_variable_get_object(ret); |
| 2672 | for (u16 i = 0; i < retObj->type->props.name_count; i++) |
| 2673 | retObj->prop[i] = bv_variable_create_float(signData[i]); |
| 2674 | |
| 2675 | return ret; |
| 2676 | } |
| 2677 | |
| 2678 | // frexp(float, out int) |
| 2679 | else { |
| 2680 | float x = bv_variable_get_float(bv_variable_cast(bv_type_float, args[0])); |
| 2681 | |
| 2682 | int expVal = 0; |
| 2683 | float significand = glm::frexp(x, expVal); |
| 2684 | |
| 2685 | bv_variable* outPtr = bv_variable_get_pointer(args[1]); |
| 2686 | bv_variable_set_int(outPtr, expVal); |
| 2687 | |
| 2688 | return bv_variable_create_float(significand); |
| 2689 | } |
| 2690 | } |
| 2691 | |
| 2692 | return bv_variable_create_float(0.0f); |
| 2693 | } |
| 2694 | bv_variable lib_common_ldexp(bv_program* prog, u8 count, bv_variable* args) |
| 2695 | { |
| 2696 | /* ldexp(genType, genIType), ldexp(float, int), also for genDType */ |
nothing calls this directly
no test coverage detected