第一范文网 - 专业文章范例文档资料分享平台

华中科技大学计算机系统基础实验报告

来源:用户分享 时间:2025/8/27 2:02:23 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

课 程 实 验 报 告

课程名称: 计算机系统基础

专业班级: 学 号: 姓 名: 指导教师:

报告日期: 2016年 5月 24 日

计算机科学与技术学院

目录

实验1: ................................. 错误!未定义书签。 实验2: ................................. 错误!未定义书签。 实验3: ................................. 错误!未定义书签。 实验总结 ................................. 错误!未定义书签。

实验1: 数据表示

实验概述

本实验的目的是更好地熟悉和掌握计算机中整数和浮点数的二进制编码表示。

实验中,你需要解开一系列编程“难题”——使用有限类型和数量的运算操作实现一组给定功能的函数,在此过程中你将加深对数据二进制编码表示的了解。

实验语言:c; 实验环境: linux

实验内容

需要完成 中下列函数功能,具体分为三大类:位操作、补码运算和浮点数操作。

实验设计

源码如下: /*

* lsbZero - set 0 to the least significant bit of x * Example: lsbZero(0x) = 0x * Legal ops: ! ~ & ^ | + << >> * Max ops: 5 * Rating: 1 */

int lsbZero(int x) {

* Examples: mult3div2(11) = 16 * mult3div2(-9) = -13

* mult3div2(24) = -2(overflow) * Legal ops: ! ~ & ^ | + << >>

* Max ops: 12 * Rating: 2 */

int mult3div2(int x) {

* You may assume -TMax <= x <= TMax * Legal ops: ! ~ & ^ | + << >> * Max ops: 10 * Rating: 4 */

int absVal(int x) {

* Both the argument and result are passed as unsigned int's, but * they are to be interpreted as the bit-level representations of * single-precision floating point values. * When argument is NaN, return argument..

* Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while

* Max ops: 10 * Rating: 2 */

unsigned float_abs(unsigned uf) { int x=uf&(~(1<<31)); if(x>0x7f800000) {

return uf; }

else return x; }

/*

* float_f2i - Return bit-level equivalent of expression (int) f * for floating point argument f.

* Argument is passed as unsigned int, but

* it is to be interpreted as the bit-level representation of a * single-precision floating point value.

* Anything out of range (including NaN and infinity) should return * 0xu.

* Legal ops: Any integer/unsigned operations incl. ||, &&. also if, while

* Max ops: 30 * Rating: 4 */

int float_f2i(unsigned uf) { unsigned num=0x;

int x=(uf&0x007fffff)^0x00800000; int order=0;

order=(uf&0x7f800000)>>23; if(order>158){ return num; }

if(order<127) return 0; else if(((uf>>31)&1)==1){ if(order>150){

return ~(x<<(order-150))+1; }

else return ~(x>>(150-order))+1;

华中科技大学计算机系统基础实验报告.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c2i23n1lgd45v45r56fo51lh1d7s0s50094l_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top