Pages: [1]   Go Down
Author Topic: wrong answer when makin hex --> binary conversion.  (Read 695 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 106
look at this might be intresting: http://www.youtube.com/user/Shockszzbyyous and my Website: freeduality.tk
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
i was wondering if someone could help me out smiley

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 smiley

any help would be appreciated,
and thanks in advance ! smiley

Code:

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:
  
}
Logged


Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26621
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: August 11, 2011, 03:46:04 pm by AWOL » Logged

"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.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34724
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 106
look at this might be intresting: http://www.youtube.com/user/Shockszzbyyous and my Website: freeduality.tk
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yes i see thank you guys i didn't know that smiley-razz 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 smiley-razz
Logged


Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

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

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26621
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The apostrophe generally indicates ownership, not plurality.
...and also elision (e.g. "isn't" == "is not")
Logged

"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.

Offline Offline
Full Member
***
Karma: 0
Posts: 106
look at this might be intresting: http://www.youtube.com/user/Shockszzbyyous and my Website: freeduality.tk
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i know i use that ' to much,
you can understand what i'm saying right? smiley-razz
Logged


Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 639
Posts: 34724
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes but it makes you seem less intelligent that you probably are.
Logged

Pages: [1]   Go Up
Jump to: