C + +, matlab Two numerical division, take the remainder of the result, divide the number of parts of Matlab Two integer divide the result is integral type, floating point type __c++

Source: Internet
Author: User
Tags integer division
</pre><p></p><pre code_snippet_id= "1932623" snippet_file_name= "blog_20161019_2_405111" name= "Code" class= "cpp" > int bb = ten;
  int cc = aa% BB;
  int dd = aa/bb;
  cout << cc << Endl << dd <<endl;
  cout << "CNT:" << cnt << Endl;


Output results:

3

23


%: Take the remainder

/: Divide division to divide the number of parts


(The difference with MATLAB code)


  Double AA = 24.4;
  Double bb = 3.2;
  Double cc = aa/bb;
  cout << "AA  bb cc:" << aa << "  " << bb << "  " << cc <<endl;

  Double A = 24.4;
  int b = 3;
  Double C = A/b;
  cout << "a  b C:" << a << "  " << b << "  " << c << Endl;





Matlab:


% to calculate gain% of RGB three channel

Rgain = Ymax/rav
Ggain = Ymax/gav
Bgain = Ymax/bav


Ymax = 235

Rav = 133.4989

Gav = 123.8576
Bav = 149.9403

Odd, you need to use the gain factor, but the output is an integer 2

Command calculation at the command line can clearly output floating-point results


/rdivide matlab Help document Explanation:

Integer Division

Divide a int16 scalar value by each element of the int16 vector.

A = Int16 (a);
b = Int16 ([3 4 6]);
x = a./b
x =

      3      3      2

Matlab®rounds the results when dividing integer data types. For integers, rounding the result is a solution:

Divides the% two integers, converts the denominator to a double, and the output is a double type.

SUMR = SUM (sum (R))
Rav = Double (SUMR)/CNDDT

Output results:
Rav = 133.4989







Related Article

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.