(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 25128, 737] NotebookOptionsPosition[ 23082, 662] NotebookOutlinePosition[ 23532, 680] CellTagsIndexPosition[ 23489, 677] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["\<\ Math 481A California State University, Northridge IEEE binary standard\ \>", "Section"], Cell["\<\ \[Copyright]2007 BE Shapiro v6. Compatible\ \>", "Subsection", CellChangeTimes->{{3.397782589825336*^9, 3.39778259650349*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Instructions", "Section"], Cell[TextData[{ "The functions in \"prerequisites\" must be defined first\n\nfromIEEE32[x] \ returns the exact (rational) decimal equivalent of x, where x is either a \ binary number (e.g., 101110111) or a string representing a binary number \ (e.g., \"01011101111\"). If x has fewer than 32 bits then zeroes will be \ added to the right. \n\nIf the first bit is zero, the argument must be passed \ as a string, not a number, because otherwise ", StyleBox["Mathematica", FontSlant->"Italic"], " will ignore all leading zeroes.\n\nfromIEEE32[x, n] returns the real \ decimal value to n digits of accuracy.\nfrom IEEE64[x] and fromIEEE64[x, n] \ work the same way." }], "Text"] }, Closed]], Cell[CellGroupData[{ Cell["prerequisites", "Section"], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"charQ", "[", "x_", "]"}], ":=", " ", RowBox[{"And", "[", RowBox[{ RowBox[{"StringQ", "[", "x", "]"}], ",", RowBox[{ RowBox[{"StringLength", "[", "x", "]"}], "\[Equal]", "1"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"bitQ", "[", "\"\<1\>\"", "]"}], ":=", " ", "True"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"bitQ", "[", "\"\<0\>\"", "]"}], ":=", " ", "True"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"bitQ", "[", RowBox[{"x_", "?", "charQ"}], "]"}], ":=", " ", "False"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"bitQ", "[", RowBox[{"s_", "?", "StringQ"}], "]"}], ":=", RowBox[{"And", "@@", RowBox[{"bitQ", "/@", " ", RowBox[{"Characters", "[", "s", "]"}]}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"bitQ", "[", RowBox[{"x_", "?", "NumberQ"}], "]"}], ":=", " ", RowBox[{"bitQ", "[", RowBox[{"ToString", "[", "x", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]"}], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["fromIEEE32", "Section"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"fromIEEE32", "[", RowBox[{"x_", "?", "bitQ"}], "]"}], ":=", " ", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "b", ",", "s", ",", " ", "e", ",", " ", "m", ",", " ", "mult", ",", "k"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"b", "=", "x"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"NumberQ", "[", "x", "]"}], ",", " ", RowBox[{"b", "=", RowBox[{"ToString", "[", "b", "]"}]}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"Characters", "[", "b", "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", "b", "]"}], "<", "32"}], ",", " ", RowBox[{ RowBox[{"Print", "[", RowBox[{ RowBox[{"Length", "[", "b", "]"}], ",", "\"\< bits input: padding the right with \>\"", ",", RowBox[{"32", "-", RowBox[{"Length", "[", "b", "]"}]}], ",", "\"\< zeroes.\>\""}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"PadRight", "[", RowBox[{"b", ",", "32", ",", "0"}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", " ", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", "b", "]"}], ">", "32"}], ",", " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", RowBox[{ RowBox[{"Length", "[", "b", "]"}], ",", "\"\< bits input: ignoring the last \>\"", ",", RowBox[{ RowBox[{"Length", "[", "b", "]"}], "-", "32"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"Take", "[", RowBox[{"b", ",", " ", "32"}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"b", "/.", RowBox[{"{", RowBox[{ RowBox[{"\"\<1\>\"", "\[Rule]", " ", "1"}], ",", " ", RowBox[{"\"\<0\>\"", "\[Rule]", " ", "0"}]}], "}"}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"s", "=", RowBox[{"b", "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"e", "=", RowBox[{"Take", "[", RowBox[{"b", ",", " ", RowBox[{"{", RowBox[{"2", ",", "9"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"m", "=", RowBox[{"Drop", "[", RowBox[{"b", ",", "9"}], "]"}]}], ";", " ", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"ToString", "[", "s", "]"}], ",", " ", "\"\< e=\>\"", ",", RowBox[{"StringJoin", "@@", RowBox[{"ToString", "/@", "e"}]}], ",", " ", "\"\< m=\>\"", ",", RowBox[{"StringJoin", "@@", RowBox[{"ToString", "/@", "m"}]}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"mult", "=", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"2", "^", "k"}], ",", " ", RowBox[{"{", RowBox[{"k", ",", "0", ",", " ", "7"}], "}"}]}], "]"}], "//", "Reverse"}]}], ";", "\[IndentingNewLine]", RowBox[{"e", "=", RowBox[{"e", ".", "mult"}]}], ";", "\[IndentingNewLine]", RowBox[{"mult", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "/", "2"}], ")"}], "^", "k"}], ",", " ", RowBox[{"{", RowBox[{"k", ",", "1", ",", "23"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"m", "=", RowBox[{"m", ".", "mult"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "e"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", " ", RowBox[{"N", "[", RowBox[{"m", ",", "30"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"e", "\[Equal]", "0"}], " ", "\[And]", " ", RowBox[{"m", "\[NotEqual]", " ", "0"}]}], ",", RowBox[{"Return", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"(", RowBox[{"-", "1"}], ")"}], "^", "s"}], " ", ")"}], " ", RowBox[{"(", RowBox[{"2", "^", RowBox[{"-", "126"}]}], ")"}], RowBox[{"(", "m", ")"}]}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"e", "\[Equal]", "255"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"m", "\[Equal]", "0"}], " ", "\[And]", " ", RowBox[{"s", "\[Equal]", "1"}]}], ",", " ", RowBox[{"Return", "[", RowBox[{"-", "\[Infinity]"}], "]"}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"m", "\[Equal]", "0"}], " ", "\[And]", " ", RowBox[{"s", "\[Equal]", "0"}]}], ",", " ", RowBox[{"Return", "[", "\[Infinity]", "]"}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"Return", "[", "Indeterminate", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"e", "==", "m", "==", "s", "==", "0"}], ",", " ", RowBox[{"Return", "[", "0", "]"}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"e", "==", "m", "\[Equal]", "0"}], "\[And]", " ", RowBox[{"s", "\[Equal]", "1"}]}], ",", " ", RowBox[{"Return", "[", RowBox[{"-", "0"}], "]"}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"(", RowBox[{"-", "1"}], ")"}], "^", "s"}], " ", ")"}], "*", RowBox[{"(", RowBox[{"2", "^", RowBox[{"(", RowBox[{"e", "-", "127"}], ")"}]}], ")"}], "*", RowBox[{"(", RowBox[{"1", "+", "m"}], ")"}]}], " ", "]"}], ";"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"fromIEEE32", "[", "x_", "]"}], ":=", " ", RowBox[{"Print", "[", "\"\\"", "]"}]}], ";"}]}], " "}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Examples - 32 bit", "Section"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"x", "=", RowBox[{"fromIEEE32", "[", "10101010111110000011111111", "]"}]}]], "Input"], Cell[CellGroupData[{ Cell[BoxData[ InterpretationBox[ RowBox[{ "26", "\[InvisibleSpace]", "\<\" bits input: padding the right with \"\>", "\[InvisibleSpace]", "6", "\[InvisibleSpace]", "\<\" zeroes.\"\>"}], SequenceForm[26, " bits input: padding the right with ", 6, " zeroes."], Editable->False]], "Print", CellChangeTimes->{3.397782545954921*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Binary s=\"\>", "\[InvisibleSpace]", "\<\"1\"\>", "\[InvisibleSpace]", "\<\" e=\"\>", "\[InvisibleSpace]", "\<\"01010101\"\>", "\[InvisibleSpace]", "\<\" m=\"\>", "\[InvisibleSpace]", "\<\"11110000011111111000000\"\>"}], SequenceForm[ "Binary s=", "1", " e=", "01010101", " m=", "11110000011111111000000"], Editable->False]], "Print", CellChangeTimes->{3.39778254595854*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Base 10 e=\"\>", "\[InvisibleSpace]", "85"}], SequenceForm["Base 10 e=", 85], Editable->False]], "Print", CellChangeTimes->{3.397782546278998*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Base 10 m=\"\>", "\[InvisibleSpace]", "0.93944549560546875`30."}], SequenceForm["Base 10 m=", 0.93944549560546875`30.], Editable->False]], "Print", CellChangeTimes->{3.39778254628307*^9}] }, Open ]], Cell[BoxData[ RowBox[{"-", FractionBox["254207", "576460752303423488"]}]], "Output", CellChangeTimes->{3.3977825462866573`*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"N", "[", RowBox[{"x", ",", "25"}], "]"}]], "Input"], Cell[BoxData[ RowBox[{"-", "4.40978850657636201049172086641192436`25.*^-13"}]], "Output", CellChangeTimes->{3.397782549636424*^9}] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"N", "[", RowBox[{ RowBox[{"fromIEEE32", "[", "\"\<1111111111\>\"", "]"}], ",", "50"}], "]"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData[ InterpretationBox[ RowBox[{ "10", "\[InvisibleSpace]", "\<\" bits input: padding the right with \"\>", "\[InvisibleSpace]", "22", "\[InvisibleSpace]", "\<\" zeroes.\"\>"}], SequenceForm[10, " bits input: padding the right with ", 22, " zeroes."], Editable->False]], "Print", CellChangeTimes->{3.397782552661463*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Binary s=\"\>", "\[InvisibleSpace]", "\<\"1\"\>", "\[InvisibleSpace]", "\<\" e=\"\>", "\[InvisibleSpace]", "\<\"11111111\"\>", "\[InvisibleSpace]", "\<\" m=\"\>", "\[InvisibleSpace]", "\<\"10000000000000000000000\"\>"}], SequenceForm[ "Binary s=", "1", " e=", "11111111", " m=", "10000000000000000000000"], Editable->False]], "Print", CellChangeTimes->{3.397782552667351*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Base 10 e=\"\>", "\[InvisibleSpace]", "255"}], SequenceForm["Base 10 e=", 255], Editable->False]], "Print", CellChangeTimes->{3.397782552670445*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Base 10 m=\"\>", "\[InvisibleSpace]", "0.5`30."}], SequenceForm["Base 10 m=", 0.5`30.], Editable->False]], "Print", CellChangeTimes->{3.3977825526732483`*^9}] }, Open ]], Cell[BoxData["Indeterminate"], "Output", CellChangeTimes->{3.397782552675961*^9}] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell["fromIEEE64", "Section"], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"fromIEEE64", "[", RowBox[{"x_", "?", "bitQ"}], "]"}], ":=", " ", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "b", ",", "s", ",", " ", "e", ",", " ", "m", ",", " ", "mult", ",", "k"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"b", "=", "x"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"NumberQ", "[", "x", "]"}], ",", " ", RowBox[{"b", "=", RowBox[{"ToString", "[", "b", "]"}]}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"Characters", "[", "b", "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", "b", "]"}], "<", "64"}], ",", " ", RowBox[{ RowBox[{"Print", "[", RowBox[{ RowBox[{"Length", "[", "b", "]"}], ",", "\"\< bits input: padding the right with \>\"", ",", RowBox[{"64", "-", RowBox[{"Length", "[", "b", "]"}]}], ",", "\"\< zeroes.\>\""}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"PadRight", "[", RowBox[{"b", ",", "64", ",", "0"}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", " ", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"Length", "[", "b", "]"}], ">", "64"}], ",", " ", "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", RowBox[{ RowBox[{"Length", "[", "b", "]"}], ",", "\"\< bits input: ignoring the last \>\"", ",", RowBox[{ RowBox[{"Length", "[", "b", "]"}], "-", "64"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"Take", "[", RowBox[{"b", ",", " ", "64"}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"b", "=", RowBox[{"b", "/.", RowBox[{"{", RowBox[{ RowBox[{"\"\<1\>\"", "\[Rule]", " ", "1"}], ",", " ", RowBox[{"\"\<0\>\"", "\[Rule]", " ", "0"}]}], "}"}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"s", "=", RowBox[{"b", "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"e", "=", RowBox[{"Take", "[", RowBox[{"b", ",", " ", RowBox[{"{", RowBox[{"2", ",", "12"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"m", "=", RowBox[{"Drop", "[", RowBox[{"b", ",", "12"}], "]"}]}], ";", " ", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"ToString", "[", "s", "]"}], ",", " ", "\"\< e=\>\"", ",", RowBox[{"StringJoin", "@@", RowBox[{"ToString", "/@", "e"}]}], ",", " ", "\"\< m=\>\"", ",", RowBox[{"StringJoin", "@@", RowBox[{"ToString", "/@", "m"}]}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"mult", "=", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"2", "^", "k"}], ",", " ", RowBox[{"{", RowBox[{"k", ",", "0", ",", " ", "10"}], "}"}]}], "]"}], "//", "Reverse"}]}], ";", "\[IndentingNewLine]", RowBox[{"e", "=", RowBox[{"e", ".", "mult"}]}], ";", "\[IndentingNewLine]", RowBox[{"mult", " ", "=", " ", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"1", "/", "2"}], ")"}], "^", "k"}], ",", " ", RowBox[{"{", RowBox[{"k", ",", "1", ",", "52"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"m", "=", RowBox[{"m", ".", "mult"}]}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", "e"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", " ", RowBox[{"N", "[", RowBox[{"m", ",", "30"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"e", "\[Equal]", "0"}], " ", "\[And]", " ", RowBox[{"m", "\[NotEqual]", " ", "0"}]}], ",", RowBox[{"Return", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"(", RowBox[{"-", "1"}], ")"}], "^", "s"}], " ", ")"}], " ", RowBox[{"(", RowBox[{"2", "^", RowBox[{"-", "1022"}]}], ")"}], RowBox[{"(", "m", ")"}]}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"e", "\[Equal]", "2047"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"m", "\[Equal]", "0"}], " ", "\[And]", " ", RowBox[{"s", "\[Equal]", "1"}]}], ",", " ", RowBox[{"Return", "[", RowBox[{"-", "\[Infinity]"}], "]"}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"m", "\[Equal]", "0"}], " ", "\[And]", " ", RowBox[{"s", "\[Equal]", "0"}]}], ",", " ", RowBox[{"Return", "[", "\[Infinity]", "]"}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"Return", "[", "Indeterminate", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"e", "==", "m", "==", "s", "==", "0"}], ",", " ", RowBox[{"Return", "[", "0", "]"}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"e", "==", "m", "\[Equal]", "0"}], "\[And]", " ", RowBox[{"s", "\[Equal]", "1"}]}], ",", " ", RowBox[{"Return", "[", RowBox[{"-", "0"}], "]"}]}], "]"}], ";", " ", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"(", RowBox[{"-", "1"}], ")"}], "^", "s"}], " ", ")"}], "*", RowBox[{"(", RowBox[{"2", "^", RowBox[{"(", RowBox[{"e", "-", "1023"}], ")"}]}], ")"}], "*", RowBox[{"(", RowBox[{"1", "+", "m"}], ")"}]}], " ", "]"}], ";"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"fromIEEE64", "[", RowBox[{ RowBox[{"x_", "?", "bitQ"}], ",", RowBox[{"n_", "?", "NumberQ"}]}], "]"}], ":=", " ", RowBox[{"N", "[", RowBox[{ RowBox[{"fromIEEE64", "[", "x", "]"}], ",", "n"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"fromIEEE64", "[", "x__", "]"}], ":=", " ", RowBox[{"Print", "[", "\"\\"", "]"}]}], ";"}]}], " "}]], "Input"] }, Closed]], Cell[CellGroupData[{ Cell["Example", "Section"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"fromIEEE64", "[", RowBox[{"\"\<0100000000101011\>\"", ",", "25"}], "]"}]], "Input"], Cell[CellGroupData[{ Cell[BoxData[ InterpretationBox[ RowBox[{ "16", "\[InvisibleSpace]", "\<\" bits input: padding the right with \"\>", "\[InvisibleSpace]", "48", "\[InvisibleSpace]", "\<\" zeroes.\"\>"}], SequenceForm[16, " bits input: padding the right with ", 48, " zeroes."], Editable->False]], "Print", CellChangeTimes->{3.397782568474906*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Binary s=\"\>", "\[InvisibleSpace]", "\<\"0\"\>", "\[InvisibleSpace]", "\<\" e=\"\>", "\[InvisibleSpace]", "\<\"10000000010\"\>", "\[InvisibleSpace]", "\<\" m=\"\>", "\[InvisibleSpace]", \ "\<\"1011000000000000000000000000000000000000000000000000\"\>"}], SequenceForm[ "Binary s=", "0", " e=", "10000000010", " m=", "1011000000000000000000000000000000000000000000000000"], Editable->False]], "Print", CellChangeTimes->{3.397782568477459*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Base 10 e=\"\>", "\[InvisibleSpace]", "1026"}], SequenceForm["Base 10 e=", 1026], Editable->False]], "Print", CellChangeTimes->{3.397782568480359*^9}], Cell[BoxData[ InterpretationBox[ RowBox[{"\<\"Base 10 m=\"\>", "\[InvisibleSpace]", "0.6875`30."}], SequenceForm["Base 10 m=", 0.6875`30.], Editable->False]], "Print", CellChangeTimes->{3.397782568481915*^9}] }, Open ]], Cell[BoxData["13.5`25."], "Output", CellChangeTimes->{3.397782568483436*^9}] }, Open ]] }, Closed]] }, WindowSize->{796, 753}, WindowMargins->{{436, Automatic}, {Automatic, 101}}, ShowSelection->True, Magnification->1.5, FrontEndVersion->"6.0 for Mac OS X x86 (32-bit) (June 19, 2007)", StyleDefinitions->FrontEnd`FileName[{"Creative"}, "NaturalColor.nb", CharacterEncoding -> "UTF-8"] ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 97, 4, 168, "Section"], Cell[690, 29, 138, 5, 96, "Subsection"] }, Open ]], Cell[CellGroupData[{ Cell[865, 39, 31, 0, 108, "Section"], Cell[899, 41, 680, 12, 304, "Text"] }, Closed]], Cell[CellGroupData[{ Cell[1616, 58, 32, 0, 61, "Section"], Cell[1651, 60, 1175, 38, 221, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[2863, 103, 29, 0, 61, "Section"], Cell[2895, 105, 7381, 182, 1093, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[10313, 292, 36, 0, 61, "Section"], Cell[CellGroupData[{ Cell[10374, 296, 111, 2, 55, "Input"], Cell[CellGroupData[{ Cell[10510, 302, 341, 7, 30, "Print"], Cell[10854, 311, 446, 10, 30, "Print"], Cell[11303, 323, 200, 5, 30, "Print"], Cell[11506, 330, 245, 6, 30, "Print"] }, Open ]], Cell[11766, 339, 132, 3, 78, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[11935, 347, 78, 2, 55, "Input"], Cell[12016, 351, 132, 2, 59, "Output"] }, Open ]], Cell[CellGroupData[{ Cell[12185, 358, 136, 4, 55, "Input"], Cell[CellGroupData[{ Cell[12346, 366, 343, 7, 30, "Print"], Cell[12692, 375, 447, 10, 30, "Print"], Cell[13142, 387, 202, 5, 30, "Print"], Cell[13347, 394, 212, 5, 30, "Print"] }, Open ]], Cell[13574, 402, 82, 1, 55, "Output"] }, Open ]] }, Closed]], Cell[CellGroupData[{ Cell[13705, 409, 29, 0, 61, "Section"], Cell[13737, 411, 7713, 193, 1117, "Input"] }, Closed]], Cell[CellGroupData[{ Cell[21487, 609, 26, 0, 61, "Section"], Cell[CellGroupData[{ Cell[21538, 613, 110, 2, 55, "Input"], Cell[CellGroupData[{ Cell[21673, 619, 343, 7, 30, "Print"], Cell[22019, 628, 517, 12, 54, "Print"], Cell[22539, 642, 204, 5, 30, "Print"], Cell[22746, 649, 216, 5, 30, "Print"] }, Open ]], Cell[22977, 657, 77, 1, 55, "Output"] }, Open ]] }, Closed]] } ] *) (* End of internal cache information *)