Embedded system design using c, Computer Engineering

Assignment Help:

W To date we have discussed elementary high level language programming and low level assembler programming, one of the benefits of C is the integration of both , this requires a revisit to 'C' to discover advanced features.

Number ranges and logical expression within C

  Within C we have seen and used various type functions i.e. int, char, Boolean, float. These types are limited in storage size, consider the following example.

Example
  
  Write a program to input two integer numbers and display the addition.
 
Answer
 
  #include stdio.h
  void main()
  {
  /*Author : Mr James Mc Carren 
  Company: Staffordshire University 
   Date: 26th August 2012 
  Version 1.0 
  Function : To add two integers numbers together       
   Modifications:   none*/
  char prompt;
  short int a,b;
  printf("Please enter in number 1  : ");
  scanf("%d",&a);
  printf("\n\rPlease enter in number 2 :");
  scanf("%d",&b);
  printf("\n\r The total of %d + %d is %d",a,b,a+b);
  printf("Press any key to exit \n\r");
  scanf("\n%c",&prompt);
  }   
 
  If we enter in the following numbers 
 
  Number 1 40000
  Number 2 50000
 
The program produces
 
  Please enter in number 1  : 40000
 
  Please enter in number 2 :  50000
 
   The total of -25536 +-15536 is 24464

 There appears to be a limit on the maximum number stored in a integer variable.  This is true for all the variables used so far i.e
 
  Char    127 to -128
  int    32767 to -32768
  float     3.40282347e+38 to 1.17549435e-38
 
To extend these ranges we can use extended types i.e
 
  long int    2147483647 to -2147483648
  double   1.7976931348623157e+308 to 2.2250738585072014e-308
 
To extend the ranges even further we can use the unsigned type, this removes the sign space. This is commonly used in microprocessor development systems are hex/binary is rarely signed i.e.

     unsigned char 
    unsigned int
    unsigned  float
    unsigned double
    unsigned long int

This is why when we cast data; it may not always work i.e trying to fit a float into a int,  Because a float is physically bigger than an int . Coupled with this is a extended range of format commands i.e. %lx %ld ' long hex long decimal' %ux %ud ' unsigned long hex unsigned long int.


Related Discussions:- Embedded system design using c

Social media strategy design, For this phase of the project you are require...

For this phase of the project you are required to formulate a social media strategy for a product/service/business/concept/charity...etc. the strategy can include technologies such

Operations from events, Operations from events During analysis, events...

Operations from events During analysis, events which are sent to target objects. An operation on these object are presented as labels on transitions and should not be explicit

Calculate blocking probability in a two stage network, In a two stage netwo...

In a two stage network there are 512 inlets and outlets, r=s=24. If the probability that a given inlet is active is 0.8, calculate: Blocking probability Given: N =M =512,

Show the programmes for parallel systems, Q. Show the Programmes for Parall...

Q. Show the Programmes for Parallel Systems? Adding elements of an array using two processor      int sum, A[ n] ;  //shared variables

Explain vehicle tracking system, Case Study - A taxi company has 200 taxies...

Case Study - A taxi company has 200 taxies. The company provides its services to all the nine districts in Mauritius, about 20 taxies per district. A taxi is normally attached to

Boolean algebra, https://www.chegg.com/homework-help/questions-and-answers/...

https://www.chegg.com/homework-help/questions-and-answers/57-karnaugh-maps-7-diagram-shows-system-hot-chocolate-drinks-vending-machine-vending-machi-q91661540

What is the cih, CIH, also known  as Chernobyl or Spacefiller, is a Microso...

CIH, also known  as Chernobyl or Spacefiller, is a Microsoft Windows computer virus which first emerged in 1998. It is one of the most damaging viruses, overwriting critical inform

What is the difference between proc. sent by val and by ref, What is the di...

What is the difference between proc. sent BY VAL and By Ref? BY VAL: Alters will not be reflected back to the variable. By REF: Alters will be reflected back to that variab

What do you mean by keyboard touch, Q. What do you mean by Keyboard Touch? ...

Q. What do you mean by Keyboard Touch? When employing a keyboard the most important factor is the feel of keyboard it implies that how typing feels on that specific keyboard.

Assessing heuristic searches-artificial intelligence, Assessing Heuristic S...

Assessing Heuristic Searches Given a specific problem you want to create an agent to solve, there can be more than one way of specifying it as a search problem, more than one o

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd