啦啦啦拉拉裤 2021-10-03 19:42 采纳率: 69.1%
浏览 60
已结题

C语言问题 使用位运算将浮点数乘以 2048

请问这个要怎么解决?在“PUT YOUR CODE HERE”写内容,前面内容不要改动,按照要求来写,da佬编写1下,写内容,蟹蟹大lao,可以用下面的例子来测试是否正确。

img

img

img

 
// Multiply a float by 2048 using bit operations only
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include "floats.h"
// float_2048 is given the bits of a float f as a uint32_t
// it uses bit operations and + to calculate f * 2048
// and returns the bits of this value as a uint32_t
//
// if the result is too large to be represented as a float +inf or -inf is returned
//
// if f is +0, -0, +inf or -inf, or Nan it is returned unchanged
//
// float_2048 assumes f is not a denormal number
//
uint32_t float_2048(uint32_t f) {
    // PUT YOUR CODE HERE
    return 42;
}

  • 写回答

2条回答 默认 最新

  • CSDN专家-sinJack 2021-10-03 20:43
    关注

    左移11位就相当于乘以2048

    uint32_t float_2048(uint32_t f) {
        return f<<11;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月19日
  • 已采纳回答 10月11日
  • 创建了问题 10月3日

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)