Tutorial Addendum On C# - Allotment B - Bifold Representation of float and bifold Ethics

ios appcolt wargamesios strategygamesios
 31 December 18:00   

    



    



    

Rule 7: If the backer basic abundance all 1s, the atom component

    

is aloof for addition operation uses.

    



    

For abrogating values, aggregate is identical with the absolute numbers,

    

except the assurance bit.

    



    

The constant, 127, acclimated in backer allotment of the announcement is alleged the bias.

    

For double-precision standard, the bent is 1023.

    



    

The IEEE 754 standards are aswell alleged bifold amphibian point amount standards,

    

because:

    



        

  • The amount is bidding in bifold format.


  •     

  • The bifold point is floated around.


  •     



    



    

Finally, let s see a program I wrote to catechumen a "float" amount into the IEEE

    

754 announcement format:

    



    

using System;

    

public chic IeeeFloat {

    

clandestine const int fraction_size = 23;

    

clandestine const int bent = 127;

    

clandestine float original_value;

    

clandestine float value;

    

clandestine int sign;

    

clandestine continued exponent;

    

clandestine int lead;

    

clandestine int[] fraction;

    



    

accessible IeeeFloat(float v) {

    

original_value = v;

    

amount = original_value;

    



    

assurance = 1;

    

advance = 0;

    

backer = 0;

    

atom = new int[fraction_size];

    



    

int i;

    

for (i=0; i<fraction_size; i++) {

    

fraction[i] = 0;

    

}

    



    

// of course, alive on the assurance first

    

if (value==0.0f) {

    

assurance = 1;

    

} abroad if (value==-0.0f) { // not abiding if this detects the -0

    

assurance = -1;

    

amount = -1.0f*value;

    

} abroad if (value<0.0f) {

    

assurance = -1;

    

amount = -1.0f*value;

    

}

    



    

if (value>0.0f) {

    

// now, the backer part

    

while (value>=2.0f) {

    

exponent++;

    

amount = value/2.0f;

    

}

    

while (value<1.0f && exponent>-bias) {

    

exponent--;

    

amount = value*2.0f;

    

}

    



    

// the implict arch bit

    

if (value>=1.0f) {

    

amount = value-1.0f;

    

amount = value*2.0f;

    

advance = 1;

    

} abroad

    

advance = 0;

    

}

    

// time for the atom part

    

for (i=0; i<fraction_size; i++) {

    

if (value>=1.0f) {

    

fraction[i] = 1;

    

amount = value-1.0f;

    

} abroad {

    

fraction[i] = 0;

    

}

    

amount = value*2.0f;

    

}

    

}

    

}

    

accessible cord toBinaryExpression() {

    

cord str = "";

    

if (sign<0) str = str + "-";

    

str = str + "b(" + lead;

    

str = str + ".";

    

for (int i=0; i<fraction_size; i++) {

    

str = str + fraction[i];

    

}

    

str = str + ")*2**(" + backer + ")";

    

acknowledgment str;

    

}

    



    

 


Tags: value, float, values, public

 value, fraction, exponent, private, float, binary, original, value*2, public, values, double, , str str, fraction size, value value*2, value value, private int, original value, int fraction, i< fraction, i< fraction size, int fraction size,

Share Tutorial Addendum On C# - Allotment B - Bifold Representation of float and bifold Ethics:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  c-sharp