Go Down

### Topic: wrong answer when makin hex --> binary conversion. (Read 1 time)previous topic - next topic

#### duality

##### Aug 11, 2011, 10:33 pm
Hello,
i was wondering if someone could help me out

so i was experimenting with conversion of value's

i tried to turn 5FFF hex into a binairy number that gave me 100011001000110

to see if this was right i put 5FFF in a online hex to binary converter and that gave me:
0101111111111111

this one must be right since i need 16 bits for my project.

ow and when i tried to make a hex from that binary number it gave me 3130

so the serial monitor can't display letters or?

i am not new to the arduino, i am no pro either so just learning

any help would be appreciated,

Code: [Select]
`void setup() {  // put your setup code here, to run once:    Serial.begin(9600);  Serial.println('5FFF', BIN);  delay(1000);  Serial.println(100011001000110, HEX);}void loop() {  // put your main code here, to run repeatedly:  }`

#### AWOL

#1
##### Aug 11, 2011, 10:40 pmLast Edit: Aug 11, 2011, 10:46 pm by AWOL Reason: 1
Quote
Serial.println('5FFF', BIN);
delay(1000);
Serial.println(100011001000110, HEX);

The first print has a multichacter constant as parameter (not a string), the second has a large decimal number as parameter.
What did you intend?

0x5FFF is the normal way of writing a hex constant. No quotes.
0b100011001000110 is one way of writing a binary constant.

0100 is an octal constant.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### Grumpy_Mike

#2
##### Aug 11, 2011, 10:49 pm
Why do you want to convert them? They are stored as a bit pattern and it is only when you want to print it out do you need to specify a pretty format. And the print statement will do that for you.
Serial.Print(0x5FFF, BIN);
Will print out the hex value of 5FFF in binary.

#### duality

#3
##### Aug 12, 2011, 12:54 am
yes i see thank you guys i didn't know that i learned something now.
i tried to look it up but could really find any answers,

was just experimenting away with the serial monitor and how to change the notation of a value.
experimenting give's me new idea's for project's anyways

#### cmiyc

#4
##### Aug 12, 2011, 03:00 am
Quote
experimenting give's me new idea's for project's

You are aware that in English when you make a word plural, it is not necessary (or correct) to use an apostrophe?  The apostrophe generally indicates ownership, not plurality.

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

#### AWOL

#5
##### Aug 12, 2011, 08:17 am
Quote
The apostrophe generally indicates ownership, not plurality.

...and also elision (e.g. "isn't" == "is not")
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

#### duality

#6
##### Aug 12, 2011, 02:36 pm
i know i use that ' to much,
you can understand what i'm saying right?

#### Grumpy_Mike

#7
##### Aug 12, 2011, 10:28 pm
Yes but it makes you seem less intelligent that you probably are.

Go Up