Floating point operations

This is a discussion on Floating point operations within the C Programming forums, part of the General Programming Boards category; Hi All, Bit of a newbie question. I am working with an embedded processor, and have just ported over the ...

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    3

    Floating point operations

    Hi All,

    Bit of a newbie question. I am working with an embedded
    processor, and have just ported over the hardware for a floating
    point unit.

    The GNU compiler that I am using automatically uses S/w floating
    point for these operations.

    Is it possible to overload the + - and * operations in C ?
    (Currently my FPU does not support divide)

    Any recommendations ?

    Cheers

    Kris Chaplin

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826

    Re: Floating point operations

    Originally posted by kjc197
    Is it possible to overload the + - and * operations in C ?
    (Currently my FPU does not support divide)

    Any recommendations ?

    Cheers

    Kris Chaplin
    Compile with a C++ compiler. C doesn't support operator overloading.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    >Is it possible to overload the + - and * operations in C ?
    >(Currently my FPU does not support divide)

    Why do you need overloading? If you really need it, C does not support overloading, but C++ does. An alternative would be to create a function to do the specific kind of operation you need.

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    3

    Talking Floating Point stuff

    I would like to overload the multiplication,
    addition and subtraction. I knew this could be
    achieved in C++, shame it is not possible in C.

    What I am really trying to avoid is modifying and
    rebuilding the C compiler to have native support
    for this custom FPU.


    Thanks all...


    Kris

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I really see no other option. That is unless you don't need to use floating point operations. Could you use fixed point math?

  6. #6
    Registered User
    Join Date
    Feb 2003
    Posts
    3
    Nah, the whole point is to use the floating point unit. The processor itself did not have native support, hence the added core.


    Thanks for everyones help.

    Kris

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. doing floating operations using integer operations
    By ammalik in forum C Programming
    Replies: 10
    Last Post: 08-15-2006, 04:30 AM
  2. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 11:07 AM
  3. Floating point numbers in a binary file
    By frenchfry164 in forum C++ Programming
    Replies: 6
    Last Post: 07-31-2003, 10:04 AM
  4. 2 questions about floating point and %
    By ams80 in forum C Programming
    Replies: 2
    Last Post: 08-14-2002, 10:55 AM
  5. Replies: 2
    Last Post: 09-10-2001, 12:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21