C :: Program To Convert Bits To Bytes

May 13, 2013

I made this program to convert bits to bytes, because I'm so sick of seeing ISP's advertise speeds in megabits, which I consider an intentional attempt to decieve :P And I think I've finally understood how the return value of scanf works since the last time I posted here, so my program can check to see if an integer was entered before processing the input, but I'm stuck on how to make the whole program start over if an integer is not entered. I have a hunch it would involve a loop, but I can't figure out how to make the program start over at "How many mb do you need converted?" if an integer is not entered into scanf..Here is the code I have so far:

Code:

#include <stdio.h>
int main () {
int b, mb, kb, Byte, kB, mB, gB;
char term;
}

[code]....

and my program makes the assumption for now at least, that mb will be inputted because that's the unit of measurement that i usually see advertised, and i didn't bother making an if statement to print a conversion in terms of gigabytes because i've never heard of a connection that fast :P

View 5 Replies


ADVERTISEMENT

C/C++ :: How To Write 0 Or 1 To Binary File In Bits Not In Bytes

Aug 20, 2014

How I write a 0s or 1s to binary file in bits not in bytes how can i do that ???

View 2 Replies View Related

C++ :: How To Convert Bytes To ASCII

Feb 7, 2014

How can I convert bytes to ASCII?, I read wikipedia about UTF-8 and I understood a little bit about add or split bytes to change the value.

Now I have those bytes

0xC7 0xE6 0xC2 0x91 0x93 0x7B 0xCE 0x01

And I found a program (DCode) that convert to 64 bits little-endian, supposedly those bytes in ASCII is this.

lun, 08 julio 2013 04:28:17 UTC <---

View 3 Replies View Related

C/C++ :: How To Convert Bytes Of Data To String

Jan 24, 2014

How to convert bytes of data to string using c programming , I searched but i didnt get appropriate one .

Example : 112131(bytes) to string ("some sample")

View 4 Replies View Related

Visual C++ :: Convert 8 Bytes Into Double And Back?

Sep 5, 2013

I receive a byte stream. The first 8 bytes contain an Identification number. I receive at first the lowest byte and at the end the highest byte of the number. How can I transform this into a double value and later back into the bytestream? In the past I hard only 2 Byte values and there I could use things like MAKEWORD and HIBYTE and LOWBYTE to convert the values

View 4 Replies View Related

C/C++ :: Accommodate Double-size 8 Bytes In 4 Bytes Pointer In 32bit System?

Mar 15, 2015

how to accommodate double-size:8 bytes in 4 bytes pointer in 32bit system.

View 1 Replies View Related

C++ :: Why Address Of Object Is 6 Bytes And Not 8 Bytes On 64 Bit Linux

Mar 24, 2013

Code:
int i12 = 1001;
cout << i12 << " " << &i12 << endl;

gives the result: 0x7fff0d065098

It's 6 bytes, but I'd expect the address to be 8 bytes on my 64 bit machine. I am using Ubuntu 12.04, GNU compiler.

So, why the address is 6 bytes and not 8 bytes?

View 10 Replies View Related

C :: Calculate Number Of Bits In Type - Incorrect Result In Program

Feb 15, 2014

I have this simple program below:

Code:
#include <stdio.h>
#include <limits.h>
unsigned int rightrot(unsigned int x, unsigned int n) {

/* calculate number of bits in type */

size_t s = sizeof(x) * CHAR_BIT;

[Code] ....

The result it prints is 2684356604 on my 32-bit computer. The result I expect is as follows:
0xFF94 is 0000000000000000 1111111110010100 in binary.

Shift it right by 5:
0000000000000000 0000011111111100

Then take that result in shift it right by 27 (s is 32 and p is 5, so the difference is 27):
1111111110000000 0000000000000000

Now we use bitwise or:
0000000000000000 0000011111111100 | 1111111110000000 0000000000000000 = 1111111110000000 0000011111111100

That in decimal is 4286580732. So how does it come up with 2684356604?

View 2 Replies View Related

C++ :: Retrieve Double Number - Store 8 Bits Of Number In One Field And 16 Bits In Another

May 14, 2013

I am working on a project where I need to retrive a double number and store 8 bits of the number in one field and the other 16 bits in another field. the code below gives me an error.

lata= lat>>8;
latb = (lat & 0xff);

The error states that & and >> are illegal for double. With this in mind, can I use these on a double. If not what can I do to achieve what I am trying to do?

View 1 Replies View Related

C++ :: Program To Convert Meters To Feet

Mar 28, 2013

(Program) a. Write a C++ program to convert meters to feet. The program should request the starting meter value, the number of conversions to be made, and the increment between metric values. The display should have appropriate headings and list the meters and corresponding feet value. If the number of iterations is greater than 10, have your program substitute a default increment of 10. Use the relationship that 1 meter = 3.281 feet.

b. Run the program written in Exercise 6a on a computer. Verify that your program begins at the correct starting meter value and contains the exact number of conversions specified in your input data.

here is what have so far

#include<iostream>
#include <iomanip>
using namespace std;
// a programs to convert meter to feet
int main() {
const int MAXMETER = 10;

[Code] ....

I don't know how to have a setup where you input the values, and then will be provided the output.

View 4 Replies View Related

C :: Program That Uses Tolower To Convert Strings Into Lowercase?

Oct 6, 2014

Any simple program that uses tolower to convert strings into lowercase? Or simply just the general syntax of tolower pls. Can find it in google.

View 5 Replies View Related

C :: Program To Convert A Number Into A More Readable Format

Oct 14, 2014

I wanted to write a program to convert a number into a more readable format. It's like, if the input enters the number as 2361263 the output should be like 2,361,263. I went about this problem like extraction the number first and then if the count was equal to multiple of three i'd print ',' instead of the number.

But initially when i wrote the code for extracting a single digit from the number

Code:

#include<stdio.h>
void main() {
unsigned long long num=pow(2,50);
int count=0;
while(num!=0) {
int last_digit;

[Code]....

I know that I'd lose the number when i finish printing it, but still I only end up printing the entire number in reverse order.

As in if the input is 1234 the output is 4,321 which is not what i want.

One way of overcoming this problem is to store the values in an array and then reading then back from the end. But i wanted to know if there is a better solution than this? To extract the digits from the number in the same order as it is in the number

View 5 Replies View Related

C++ :: Program To Convert Octal Number To Decimal

Mar 27, 2013

I nead to write a program that convert an octal number to decimal number, I thought I did it right but it doesn't work.. I have to use in the first for loop as it is because it is part of the instructions (student homework).

#include <iostream>
#include <math.h>
using namespace std;
void main() {
double numOfDig, num, newNum;

[Code] ....

View 1 Replies View Related

C++ :: Program To Convert Int To Char Array Without Symbol

Apr 17, 2014

I'm writting program and need to convert int ot char array without simbol. I have tryed snprintf , but his returns array full of simbols if it is initilized elsware return full of garbidge. Is there any elegent way to aceave this? What I'm trying to aceave is liek this:

char buffer[10];
int temp = 1231423;
// Do conversation...
// After conversation char array should look like this
// 1 2 3 1 4 2 3 _ _ _
// without simbol

View 2 Replies View Related

C++ :: Program To Convert Timestamp To Hour And Days

Jan 17, 2015

I need to write a program that converts timestamp to hour and days.

View 2 Replies View Related

C++ :: Conversion Program To Convert Kilograms To Pounds

Oct 7, 2012

I need to create a conversion program to convert kilograms to pounds. The user will enter a number for weight and a char for unit of measurement K= kilo or P=pound and the program should display the other corresponding weight.

View 2 Replies View Related

C++ :: Convert Pseudo Code Into Program For Searching Value Of Array

Jun 29, 2014

What is the program of this pseudo code?

Set found to false.
Set position to -1.
Set index to 0.
While found is false and index < number of elements
If list[index] is equal to search value
found = true.
position = index.
End If
Add 1 to index.
End While.
Return position

View 5 Replies View Related

C++ :: Creating Program With Parameters To Convert Pounds To Euros

Jan 22, 2015

m creating a program with parameters to convert pounds to euros.

I keep getting this errorc2447: '{' missing function header for the line 'void showPriceInEuros' ....

#include <iostream> //for cin >> and cout <<
#include <cassert> //for assert
#include <iomanip> //for endl
#include <Windows.h>
using namespace std;
void processAPrice();
int getPriceInPounds();
int convertPriceIntoEuros(int pounds);

[Code] ....

View 1 Replies View Related

C Sharp :: Convert Log Parsing Program Written In Perl

Feb 13, 2013

Following is a script written in perl :

#Number of bugs edited in Watson Express  
#find server*/watson*/log/ -name "watson*" -type f  -newer  ./tmpoldfile ! -newer  ./tmpnewfile  | 
xargs grep "WX Edit Bug" | awk '{print $8}' | sort | uniq  | wc -l  
// 

this is log parsing string in perl based on bash file.

Need a log parsing program in C# for the same.....

View 1 Replies View Related

C++ :: Program To Convert From Fahrenheit To Celsius - Linking Error?

Jan 6, 2013

So here is the program:

//Program to convert from Fahrenheit to Celcius
#include <iostream>

double fahrenToCelsius (double t);
//precondition:
//t is a valid tempreture in Fahrenheit
//postcondition:
//returns equivalent temp. in Celcius

[Code] .....

And here is the problem:
[Linker error] C:UsersOwnerAppDataLocalTempcckex8SZ.o:fahrenToCelsius.cpp: (.text+0x3d): undefined reference to `fahrenToCelsius(double)'
collect2: ld returned 1 exit status

I'm suspecting the program maybe that I saved it wrong? I saved it as fahrentoCelsius.cpp inside the folder "Work" ( I created this folder) which is inside the folder "Dev-cpp".

View 1 Replies View Related

C++ :: Assigning Bits A Value Of 0

Feb 12, 2014

I am having a problem assigning bits a value of 0. The data is a 16 bit integer the bits greater than the 12th bit have garbage either a 0 or a 1. I would like to assign all bits greater than 12th bit the value 0 no matter what their values are. Whats the best approach.

View 5 Replies View Related

C++ :: Getting Bits In RDX After Multiply (x64)

Aug 13, 2013

Using the old fashioned (unsigned) multiplication instruction in x64 assembly multiplies RAX (64 bit register) by a 64 bit register. The answer is stored in RDX:RAX (i.e. the answer is 128 bits). Is there any way, using native c++ to get the value in RDX (higher 64 bits)? One I can think of is: right/(limit/left) e.g. if we are limited to a byte then 97*123 would overflow:

97/(255/123) = 46 times, which is RDX's (if it was one byte) value. But this is too inefficient. Is there a fast way?

View 4 Replies View Related

C++ :: Shifting Bits Away And Back

Mar 25, 2014

Value x is a 32-bit unsigned integer 3:

00000000000000000000000000000011

If we use bitwise-shift to shift all bits to the right by 2, x is 0:

00000000000000000000000000000000

If we then do a bitwise leftshift on x by 30, do we end up with:

11000000000000000000000000000000
or
00000000000000000000000000000000

In other words, when we perform right shift which clips away the least most significant bits, and then do a left shift, is it possible for those bits to reappear?

View 2 Replies View Related

C++ :: Retrieving First Three Bits Of A Number

Apr 25, 2013

I am trying to retrieve the first three bits of a number. The code that I am using should work but it isn't giving me the correct result when trying certain numbers. Below is the code I am using:

unsigned short num1, num2 = 0;
unsigned short num = 65535// binary 111111111111111
num1 = num && 0x07;// gives me 1 but should give 7(111)
num2 = num >>3;//gives me 8191, which is correct

Why I am not getting the first three correct bits(111)?

View 2 Replies View Related

C++ :: How To Reverse Bits For A Number

Sep 3, 2013

I am working on a project where I need to reverse bits for a number.

For example, if I have 110111100000000 I need to reverse it to 0000000001111011.

View 19 Replies View Related

C++ :: How To Set Certain Bits Of Unsigned Short

Aug 8, 2013

I have a double variable and depending on certain conditions I need to set certain bits of an unsigned short Variable. For example, if double var is odd I need to set the 15th bit of the unsigned short variable.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved