| | |
help
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2008
Posts: 19
Reputation:
Solved Threads: 0
following is a simple embedded c piece of code, can somebody tell me is there a problem in it ?
i am new to embedded programming. It will be great help, any pointers to this ...
thanks
pdk
c Syntax (Toggle Plain Text)
boolean new(int a) { return !(a & 7); }
thanks
pdk
Last edited by Narue; Jul 12th, 2008 at 9:44 am. Reason: Added code tags
•
•
Join Date: Jul 2008
Posts: 19
Reputation:
Solved Threads: 0
even i was not sure. because in the test, i was supposed to tell what the function is intended to do and any potential problems !!!.
i could not exactly figure out this .. i.e why any pointers to this will be helpful.
as pointed out, i was also thinking whether it will cause any problems for -ve numbers .. but without any potential soln..
i could not exactly figure out this .. i.e why any pointers to this will be helpful.
as pointed out, i was also thinking whether it will cause any problems for -ve numbers .. but without any potential soln..
•
•
Join Date: Jul 2008
Posts: 19
Reputation:
Solved Threads: 0
This function resave number, if the number is 0 its return true else its return false.
The Boolean " a & 7 ;" says if a != 0 and 7 != 0 then 1 else 0
Has you see the 7 is not needed
--------------------------------
when the number is lets say '8'. it still returns '1' .. i.e basically numbers for which lsb 3 bits are not set. it will return '1'
The Boolean " a & 7 ;" says if a != 0 and 7 != 0 then 1 else 0
Has you see the 7 is not needed
--------------------------------
when the number is lets say '8'. it still returns '1' .. i.e basically numbers for which lsb 3 bits are not set. it will return '1'
![]() |
Other Threads in the C Forum
- Previous Thread: Return values from functions
- Next Thread: Read from data file at some specified location
Views: 1582 | Replies: 23
| Thread Tools | Search this Thread |
Tag cloud for C
* adobe api append array arrays bash binarysearch char character cm copyanyfile copypdffile createcopyoffile createprocess() csyntax directory drawing dynamic executable execv feet fgets file floatingpointvalidation fork frequency function getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux highest homework i/o ide include infiniteloop initialization interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list matrix meter microsoft mqqueue multi mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scheduling segmentationfault send single socketprogramming spoonfeeding stack standard strchr string student suggestions system test testautomation unix urboc user whythiscodecausesegmentationfault win32 win32api windows.h






