IntroductionC语言练习题,主要知识点是按指定格式解析用户输入的代表数值的字符串,然后对用户输入的字符串进行加减计算,最后将计算结果按照指定的格式输出。主要涉及对字符串的解析,以及二进制,十进制,十六进制数值之间的转换,以及浮点数的二进制表示等知识。RequirementCS 211: Computer Architecture, Fall 2016Programming Assignment 2:Data Representation and Computer Arithmetic1 IntroductionThis assignment is designed to help you learn the representation, interpretation, and manipulationof data as bits. There are two parts. In the first part, you will implement a program calc to addand subtract numbers specified in different bases (multiplication is extra credit). In the secondpart, you will implement a program format that will print the decimal values of bit sequencesrepresenting integer and floating point data types.2 Numeric Base Conversion and CalculatorImplement a program called calc with the following usage interface:calc The first argument, , is either the string “+”, for addition, or “-”, for subtraction. If youwant to implement multiplication, then can also be the string “*”. (If you do implementmultiplication, make sure to say so in your readme.pdf file so that the TAs know to check yourprogram for this functionality.)The next two arguments, and are integers of arbitrary size. Each of thesenumbers will be given in the form. of:−?(b|o|d|x)d n d n−1 …d 1 d 0which can be interpreted as: a number can optionally start with a ’−’ sign, followed by a baseindicator, where b means the number is a binary number, o means octal, d means decimal, and xmeans hexadecimal. d n d n−1 …d 1 d 0 are the digits of the number.The final argument, , gives the base that the resulting number should be printedout in. Like the base indicator for the input numbers, this argument can be one of four strings: “b”for binary, “o” for octal, “d” for decimal, and “x” for hexadecimal. Your program should outputthe answer in the same form. as the input numbers (that is, the output number should follow theregular expression given above).Some examples:$ ./calc + d1111111111111111 d1111111111111111 dd22222222222222221$ ./calc + b1101 b1 dd14$ ./calc + d999999999 d1 dd1000000000$ ./calc - d10 -d4 bb1110$ ./calc + -d10 -d4 b-b1110Note that the numbers in the first example are too large to fit in a 32-bit integer type in C; this iswhy the arbitrary size is emphasized above. Using a 64-bit integer type is not the solution since theinput integers can be arbitrarily large. Rather, you need to design data structures and algorithmsthat can handle arbitrarily large numbers. Assignment update: any decimal number that weask you to handle—either an input decimal number or output in decimal format—willfit in a 32-bit integer.Important: You must write the base conversion code yourself. You may not use type-casting,libraries, or output formats in printf(). You may use standard C arithmetic operations. You mayuse the C standard libraries for functionality not related to the conversion (e.g., string handlingfunctions).Important: If calc detects an error in the inputs, it should print out an error message that startswith the string “ERROR”, followed by a string that gives an informative message about the errorthat it detected.3 Format InterpretationImplement a program called format with the following usage interface:format The first argument, , is a sequence of 32 bits. Remember that your Cprogram will get it as a string of 1 and 0 characters in the argv[1] argument to main. Thissequence ofbits represents the binary values stored in 4 contiguous bytes in memory. The leftmostbits are stored in the byte with the smallest address while the rightmost bits are stored in the bytewith the largest address.The second argument, , gives the type that you should use to interpret the input bitsequence, and can be either int (integer) or float.The formats for the input bit sequence is as follows. If the type is:int: the format is two’s complement;float: the format is IEEE 754 single precision;Note that the input bit sequence can correspond to negative numbers.2Your program should print out the decimal representation of the input bit sequence, assuming abig endian byte ordering. Floating point numbers should be printed in scientific notation, where anumber 1.5x10 5 would be printed as 1.5e5. For positive infinity, output pinf, for negative infinity,output ninf, and for “NaN”, output NaN.Here are some examples:$ ./format 01000001010000100100001101000100 int1094861636$ ./format 10000001010000100100001101000100 int-2126363836$ ./format 01000001010000100100001110000100 int1094861700$ ./format 00000000000000000000000000000001 int1$ ./format 01000000110000110100001111010100 float6.10203e0$ ./format 00111010000111111111011000001000 float6.1e-4$ ./format 10000000000000000000000000000000 float-0.0e0$ ./format 01000000010010010000111111011011 float3.141593e0Important: You must write the interpretation code yourself. You may not use type-casting,libraries, or output formats in printf(). You may use standard C arithmetic operations. You mayuse the C standard libraries for functionality not related to the value interpretation (e.g., stringhandling functions).Important: If format detects an error in the inputs, it should print out an error message thatstarts with the string “ERROR”, followed by a string that gives an informative message about theerror that it detected. For this program, you can assume that any input bit sequence that is shorteror longer than 32 bits is erroneous.4 SubmissionYou have to e-submit the assignment using Sakai. Your submission should be a tar file namedpa2.tar that can be extracted using the command:tar xf pa2.tar3Your tar file must contain:• readme.pdf: this file should describe your design and implementation of the calc program.In particular, it should detail your design, any design/implementation challenges that youran into, and an analysis (e.g., big-O analysis) of the space and time performance of yourprogram.• makefile: there should be at least the following rules in your makefile:all build both your calc and format executables.calc build your calc executable.format build your format executable.clean remove all object files and executables. Prepare for rebulding from scratch.• source code: All source code and header files necessary for building your calc and formatexecutables. These should at least include calc.c and format.c.You can build your pa2.tgz file in the following steps:1. Put all the files you want to hand in in a subdirectory called pa2.2. In the parent directory that contains pa2, invoke tar:tar cvfz pa2.tgz pa2The arguments to tar are cfvz. The c tells tar to create a new archive file. The f tells tar that thenext command line argument is the name of the output file. The z tells tar to compress the tar filewith gzip. The v just makes tar list the files it’s putting into the archive.We will compile and test your program on the iLab machines so you should make sure that yourprogram compiles and runs correctly on these machines. You must compile all C code using thegcc compiler with the -Wall flags.5 Grading Guidelines5.1 FunctionalityThis is a large class so that necessarily the most significant part of your grade will be based onprogrammatic checking of your program. That is, we will build a binary using the Makefile andsource code that you submitted, and then test the binary for correct functionality against a set ofinputs. Thus:• You should make sure that we can build your program by just running make.• You should test your code as thoroughly as you can. In particular, your code should be adeptat handling exceptional cases.Be careful to follow all instructions. If something doesn’t seem right, ask.45.2 DesignHaving said the above about functionality, design is a critical part of any programming exercise.In particular, we expect you to write reasonably efficient code based on reasonably performingalgorithms and data structures. More importantly, you need to understand the performance (timespace) implications of the algorithms and data structures you chose to use. Thus, the explanationof your design and analyses in the readme.pdf will comprise a non-trivial part of your grade. Givecareful thoughts to your writing of this file, rather than writing whatever comes to your mind in thelast few minutes before the assignment is due.5.3 Coding StyleFinally, it is important that you write “good” code. Unfortunately, we won’t be able to look atyour code as closely as we would like to give you good feedback. Nevertheless, a part of your gradewill depend on the quality of your code. Here are some guidelines for what we consider to be good:• Your code is modularized. That is, your code is split into pieces that make sense, where thepieces are neither too small nor too big.• Your code is well documented with comments. This does not mean that you should commentevery line of code. Common practice is to document each function (the parameters it takesas input, the results produced, any side-effects, and the function’s functionality) and addcomments in the code where it will help another programmer figure out what is going on.• You use variable names that have some meaning (rather than cryptic names like i).Further, you should observe the following protocols to make it easier for us to look at your code:• Define prototypes for all functions.• Place all prototype, typedef, and struct definitions in header (.h) files.• Error and warning messages should be printed to stderr using fprintf.5本团队核心人员组成主要包括BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:C/C++/C#代写Java代写IT代写Python代写辅导编程作业Matlab代写Haskell代写Processing代写Linux环境搭建Rust代写Data Structure Assginment 数据结构代写MIPS代写Machine Learning 作业 代写Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导Web开发、网站开发、网站作业ASP.NET网站开发Finance Insurace Statistics统计、回归、迭代Prolog代写Computer Computational method代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected] 微信:codehelp