Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Calculator.m
- #import "Calculator.h"
- #import "ptViewController.h"
- #import "ptViewController.m"
- @implementation Calculator : NSObject
- - (IBAction)toN{
- const long double a = 2;
- for(int i = 0 ;; i++)
- {
- if(pow(a, i) >= number)
- {
- n = i;
- break;
- }
- }
- char mas[n];
- int i = 0;
- while(number != 0)
- {
- if(number % 2 == 0)
- {
- mas[i] = '0';
- }
- else
- {
- mas[i] = '1';
- }
- number /= 2;
- i++;
- }
- /* for(int i = n; i >= 0; i--)
- {
- std::cout << mas[i];
- }*/
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment