Bug in sample programs


Results 1 to 4 of 4

Thread: Bug in sample programs

  1. #1
    Registered
    Join Date
    Mar 2008
    Location
    Canada
    Posts
    67
    Downloads
    0
    Uploads
    0

    Default Bug in sample programs

    Hi,

    I would like to point out that there is a common bug in a number of the sample C programs that I have scanned through, for example in the program HomeBrushlessSnap4.c, but in some others too.

    In these programs, the variable "k" is defined as float, and then iterated using k++ and ++k. This doesn't work, iterating floats is not part of the C programming language. k would need to be defined as an integer and then cast using (float) as needed.

    The programs as provided would not work. Just giving a heads-up ...

    Regards,
    Frank

    Similar Threads:


  2. #2
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default

    Hi Frank,

    Thanks for checking things over but that is actually not a bug. Ansi C allows the ++ operator to work with any scalar type which includes floating point. We do this somtimes intentionally because on KFLOP's DSP adding one to a floating point number can be performed simpler and faster than incrementing an integer and then converting it to floating point.

    Regards,

    Regards
    TK http://dynomotion.com


  3. #3
    Registered
    Join Date
    Mar 2008
    Location
    Canada
    Posts
    67
    Downloads
    0
    Uploads
    0

    Default

    Hi Tom,

    I stand corrected.

    Regards,
    Frank



  4. #4
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default

    Please keep looking Frank!

    Regards
    TK http://dynomotion.com


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Bug in sample programs

Bug in sample programs