Re: floating-point float
From: William L. Bahn (william_at_toomuchspam.net)
Date: 03/21/04
- Next message: Matt Suther: "is there a way to download a free c compiler and builder"
- Previous message: Jon Willeke: "Re: floating-point float"
- In reply to: andy: "floating-point float"
- Next in thread: Malcolm: "Re: floating-point float"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 20 Mar 2004 20:48:38 -0700
"andy" <andy_wil@dot.com> wrote in message
news:cV67c.416$tY6.7548@bgtnsc04-news.ops.worldnet.att.net...
> For a float-point float, how to know in C code where the decimal point
> locates?
>
> Why are float in C code different from fixed-point float?
>
> If defining fixed-point floats in 16.16 format, does this mean that all
> these fixed-point floats can not represent negative floats?
You seem to be struggling primarily because of a fundamental lack of
understanding of how numbers can be represented - regardless of whether it
is C or you are writing them on a piece of paper.
Independent of a computer language, what you are calling "float" you
probably should be calling "real". For this discussion, the two
classification of numbers are "integer" and "real" where the primary
difference is that reals are the sum of an integer and a fractional part.
Given a real number, we have to decide how to represent it in a certain
number of bits if we want to use it in a computer program and, in general,
we are free to do that however we want to and we will be okay as long as we
use our representation consistently and it poses no fundamental roadblocks
to performing the operations we wish to perform. Two common ways of
representing real values is using a fixed-point representation and using a
floating-point representation. The fixed point representation is based on
having a known and fixed location within our representation where we assume
the radix point is located. In a floating point representation we generally
take an approach akin to writing a number in exponential notation where we
have a mantissa and an exponent. The exponent contains the information about
where the radix point is located relative to the mantissa.
Most languages, such as C, have at least one means of representing real
values and a huge advantage of using that representation is that you (in
most circumstances) don't have to deal with the representation - the people
that wrote the compiler did all of that for you and as long as you use their
operators and their functions as intended you will be fine. The
representation that C compilers use is a very specific floating point
representation. If you want to use a fixed point representation, then you
are responsible for developing it (or learning about one that someone else
has developed) and implementing it and being sure that you are consistent in
its use. That's quite a bit of overhead and is seldom worth it. But there
are certainly circumstances where the benefits are worth the costs.
- Next message: Matt Suther: "is there a way to download a free c compiler and builder"
- Previous message: Jon Willeke: "Re: floating-point float"
- In reply to: andy: "floating-point float"
- Next in thread: Malcolm: "Re: floating-point float"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|