ARDUINO101 Study Notes (eight)--Library of functions

Source: Internet
Author: User
Tags bitset random seed

/********* Minimum value *********/min ()//implementation: #define MIN (a) (a) < (b)? ( A):(B))/********* Maximum Value *********/Max ()//implementation: #define MAX (A, B) ((a) > (c)? ( A):(B))/********* Absolute *********/ABS ()//implementation: #define ABS (x) ((x) >0? ( X):( -X))/********* adjustment to Interval *********///if the value of AMT is less than low, returns low if the Amt is greater than high, otherwise, returns AMT. can be used to normalized values to a rangeconstrain ()//implementation: #define CONSTRAIN (AMT, Low, High) (AMT) < (low)? ( Low):((AMT) > (high)? (high):(Amt )))/********* Mapping *********/LongMapLongXLongIn_min,LongIn_max,LongOut_min,LongOut_max);//map the x between [In_min, In_max] to [Out_min, Out_max]. Parameters: x value to map in_min map before interval In_max map interval out_min map post interval/********* exponential operation *********/DoublePOW (float Base,floatexponent);/********* Square Operation *********/DoublesqrtDoubleX//implementation: #define SQRT (x) ((x) * ( x))/********* Trigonometric Operations *********/floatSinfloatrad);floatCosfloatrad);floatTan (Flaot rad);/********* Random number operation *********/voidRandomseed (unsignedintSeed);//seed: Random seedLongRandomLongHOWBIG);//generate random number, range [0,howbig-1]/******** bit Operation *********/#defineLowbyte (W) ((w) & 0xFF)//Take low byte#defineHighbyte (W) ((W) >> 8)//take high byte#defineBitread (value, Bit) (((value) >> (bit)) & 0x01)//read a bit#defineBitwrite (value, bit, bitvalue) (Bitvalue? BitSet (value, bit): bitclear (value, bit))//write a bit#defineBitSet (value, Bit) ((value) |= (1UL << (bit))//set a bit#defineBitclear (value, Bit) ((value) &= ~ (1UL << (bit)))//empty a bit#defineBit (b) (1 << (b))//generate the appropriate bit

ARDUINO101 Study Notes (eight)--Library of functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.