Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "IspisBroja.h"
- #include <iostream>
- using namespace std;
- IspisBroja::IspisBroja() {
- this->fbroj = 0;
- }
- void IspisBroja::postaviFloat(float broj) {
- this->fbroj = broj;
- }
- void IspisBroja::ispisiBinarnoFloat() {
- unsigned char *p = (unsigned char*)&fbroj;
- cout << endl;
- for (int i = 3; i >= 0; i--) {
- for (int j = 7; j >= 0; j--) {
- (p[i] & (1 << j)) ? cout << "1" : cout << "0";
- }
- }
- cout << endl;
- }
- void IspisBroja::toBinary() {
- int fl = *(int*)&fbroj;
- cout << *(int*)&fbroj << endl;
- for (int i = sizeof(float) * 8 - 1; i >= 0; i--) {
- cout << (((1 << i) & fl) != 0 ? 1 : 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement