operations

This is a discussion on operations within the C Programming forums, part of the General Programming Boards category; Code: what would take longer? add two bytes, or add two floats or add byte and float....

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    33

    operations

    Code:
    what would take longer?
    add two bytes, or add two floats or add byte and float.

  2. #2
    Registered User
    Join Date
    May 2008
    Posts
    33
    I been thinking bout this all day, cant figure any answer

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,420
    Write your code and time it.
    Or use a profiler.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,046
    You'd have to do it several million times to notice any difference with a profiler.

    It would depend a lot on the hardware used, I would think. I can't see adding two bytes being slower than adding two floats, however.

    Also note that adding a byte and a float would involve promoting the byte to a float first. I'm not sure how efficient that is -- probably very much so.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

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. Matrix and vector operations on computers
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-11-2004, 06:36 AM
  3. String Class Operations
    By Aidman in forum C++ Programming
    Replies: 10
    Last Post: 04-06-2003, 02:29 PM
  4. Floating point operations
    By kjc197 in forum C Programming
    Replies: 5
    Last Post: 02-08-2003, 05:44 AM

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