How many elements are there in the array.

T

Tad McClellan

John Bokma said:
I quote:

"Some hexadecimal numbers are indistinguishable from a decimal number (to
both humans and computers). Therefore, some convention is usually used to
flag them."

"In mathematics and computer science, base-16, hexadecimal, or simply hex,
is a numeral system with a radix or base of 16 usually written using the ^^^^^^^
symbols 0–9 and A–F or a–f."

which agrees with my earlier post,


No it doesn't.

A "numeral" is not the same as a "number",
just as a "letter" is not the same as a "word".

and shows that hex number is ok (if we
can trust the quoted source, that is).


No, it shows that hex _numeral_ is OK.


And note that NONE of the OP's code in this thread is using
a base 16 numeral system.

hara> @result=1101

base 10.


hara> $res=00000000001000000000000000000000
hara> $res=00200000

base 8.



So, we are all flailing around trying to help this person and we
don't even know if he wants to manipulate bits (a number) or
manipulate characters (the representation of a number).

It would be nice if hara would tell us which one it is so that
we can flail in new directions...
 
J

John Bokma

Tad McClellan said:
No it doesn't.

A "numeral" is not the same as a "number",
just as a "letter" is not the same as a "word".

My earlier post stated that hex number is ok. From the same wikipedia
article:


"Some hexadecimal numbers are indistinguishable from a decimal number"
^^^^^^^

Which goes on:

"In typeset text, the indication is often a subscripted suffix such as
5A316, 5A3SIXTEEN, or 5A3HEX."

A bit more down on the same page:
"The most commonly used (or encountered) notations are the ones with a
prefix "0x" or a subscript-base 16, for *hex numbers*. For example,
both 0x2BAD and 2BAD16 represent the decimal number 11181 (or
1118110)."
No, it shows that hex _numeral_ is OK.

See above. Also, you overlooked "Some hexadecimal numbers are
indistinguishable" in my earlier post. And I doubt they are talking
about the numerals 0 to 9.

It would be nice if hara would tell us which one it is so that
we can flail in new directions...

I am afraid we will never know. A lot of these kind of posts are hit &
run.
 
H

hara

Thanks tuser
I used the script and got $hex as i required. But now
# ***************************************************
{
my $hex = '';
my $temp = $res;
while ($temp =~ s/(\d{4})$//) {
$hex = sprintf('%X', oct("0b$1")).$hex;
}
unless ($temp eq '') {
$hex = sprintf('%X', oct("0b$temp")).$hex;
}
print "Taking 4 bits at a time, result will be hex:\n";

print "$hex\n";
}
====================================================
I did like this.
$convert_hex=join('',$hex);
print "$convert_hex\n";
$search="0";
$hex=s/${search}re/E/i;

#$Base_Address='E0000000'|'$hex';


print"$hex\n";

My whole idea is to get
E0200000
if $hex=00200000
but i am not getting the output lke this.
 
H

hara

{
my $hex = '';
my $temp = $res;
while ($temp =~ s/(\d{4})$//) {
$hex = sprintf('%X', oct("0b$1")).$hex;
}
unless ($temp eq '') {
$hex = sprintf('%X', oct("0b$temp")).$hex;
}
print "Taking 4 bits at a time, result will be hex:\n";

print "$hex\n";
}
From this I am getting $hex.
In $hex the first bit is always 0
and i want to replace that zero with E
like suppose i got $hex=00200000
But i want the result ouput to be
$result=E0200000
How can i do this.
 
M

Mirco Wahab

Thus spoke hara (on 2006-05-26 11:58):
In $hex the first bit is always 0
and i want to replace that zero with E
like suppose i got $hex=00200000
But i want the result ouput to be
$result=E0200000
How can i do this.
There are lots of

There are lots of ways to do that:

...
$hex = '00200000';
$prefix = 'E';
($result=$hex) =~ s/^\d/$prefix/;

print $result;
# prints E0200000
...

One question: what is all this used for
and why do you have to use Perl?

Regards

Mirco
 
J

Jürgen Exner

hara said:
Thanks tuser
I used the script and got $hex as i required. But now
# ***************************************************
{
my $hex = '';
my $temp = $res;
while ($temp =~ s/(\d{4})$//) {
$hex = sprintf('%X', oct("0b$1")).$hex;
}
unless ($temp eq '') {
$hex = sprintf('%X', oct("0b$temp")).$hex;
}
print "Taking 4 bits at a time, result will be hex:\n";

print "$hex\n";
}
====================================================


I tried to run your script, but I'm getting
Use of uninitialized value in substitution (s///) at C:\tmp\t.pl line 6.
Use of uninitialized value in string eq at C:\tmp\t.pl line 9.
Taking 4 bits at a time, result will be hex:

Somehow I don't see where or how you initialize $res.

[...]
#$Base_Address='E0000000'|'$hex'; [...]
My whole idea is to get
E0200000
if $hex=00200000
but i am not getting the output lke this.

Are your looking for something trivial like this:

$Base_Address=0xE0000000;
$hex=0x00200000;
$res = $Base_Address + $hex;
printf "%X", $res;

This does print "E0200000". Same if you replace the addition '+' with a
bitwise or '|'. You need to decide, which functionality you actually need.

jue
 
T

Tad McClellan

hara said:
I used the script and got $hex as i required. But now
# ***************************************************
{
my $hex = '';
my $temp = $res;
while ($temp =~ s/(\d{4})$//) {
$hex = sprintf('%X', oct("0b$1")).$hex;
}
unless ($temp eq '') {
$hex = sprintf('%X', oct("0b$temp")).$hex;
}
print "Taking 4 bits at a time, result will be hex:\n";

print "$hex\n";
}
====================================================
I did like this.
$convert_hex=join('',$hex);


What do you expect that this will do for you that

$convert_hex = $hex;

does not do for you?

print "$convert_hex\n";
$search="0";
$hex=s/${search}re/E/i;


You should always enable warnings when developing Perl code!

After executing that statement, $hex must contain either a
zero or a one (ie. the value that s/// evaluates to).

Your pattern requires a '0' character followed by an 'r' character
followed by an 'e' character.

Does $_ contain that character sequence?

If not, then nothing will be replaced in $_, and $hex will contain zero.

#$Base_Address='E0000000'|'$hex';


YCJMSUAETCTMKWYMR. [1]

Bitwise or works on numbers, but you are giving it strings.

You are (attempting to) "or" the number zero with the number zero,
which will not result in anything very interesting...

My whole idea is to get
E0200000
if $hex=00200000

print 'E0200000' if $hex == 00200000;



[1] news://[email protected]
BTW: that thread from 6 years ago was the Posting Guidelines in embryo.
 
J

John Bokma

Sherm Pendley said:
You missed both the :-D on Jürgen's post, and the spelling of
"hexadezimal" in the post he replied to.

Uhm, the :-D you qouted is mine, so how I could miss that one. And
hexadezimal: I assumed Jürgen (u umlaut) used accidently German spelling.
 
S

Sherm Pendley

John Bokma said:
Uhm, the :-D you qouted is mine, so how I could miss that one. And

Pick what nits you may, the person posting the wiki link obviously missed
the :-D.
I assumed Jürgen (u umlaut)

Why are you correcting me? That's how I spelled it.

sherm--
 
S

Sherm Pendley

John Bokma said:
*sigh* Sherm, maybe use your brain before you post again? Or do you love
to quote in a too creative way?

The insults are completely uncalled-for.

I quoted the part of your message I was referring to, where you corrected my
spelling of Jürgen. Why did you correct that? As far as I can tell, I am and
have been spelling it correctly, with an umlaut.

Are you seeing something other than the correct spelling? If so, I need to
figure out if there's an encoding problem on my end that I need to fix.

sherm--
 
J

John Bokma

Sherm Pendley said:
The insults are completely uncalled-for.

Not sure about that, if they are my apologies. To me it looked like you
said I missed a :-D (which I wrote myself), and that I tried to correct
your spelling, which I didn't (see below).
I quoted the part of your message I was referring to, where you
corrected my spelling of Jürgen.

I didn't correct your spelling of Jürgen (I have no idea how you spelled
it). I assumed Jürgen, (with an u umlaut), and the spelling of Hexadezimal
had a relation.
Are you seeing something other than the correct spelling? If so, I
need to figure out if there's an encoding problem on my end that I
need to fix.

No, it wasn't about the encoding, only about the German spelling of
Hexadezimal. Jürgen is a German name AFAIK. Not sure if Jürgen has German
as a first language, but I do now and then mix Dutch in my English, or use
constructs that are clearly based on Dutch. I guessed that it was the
reason for the German spelling.

Maybe just reload the thread, and read again, I guess you mixed up some
things. Or my assumption was entirely wrong.
 
S

Sherm Pendley

John Bokma said:
Not sure about that, if they are my apologies. To me it looked like you
said I missed a :-D (which I wrote myself),

I did, but I wasn't referring to your correction of that, I was referring
to what looked to me like a correction of my spelling of Jürgen.
I didn't correct your spelling of Jürgen (I have no idea how you spelled
it). I assumed Jürgen, (with an u umlaut), and the spelling of Hexadezimal
had a relation.

That assumption wasn't clear in the message I "creatively" :-D quoted above.
To me it looks like you're telling me there's an umlaut in Jürgen.
Maybe just reload the thread, and read again, I guess you mixed up some
things. Or my assumption was entirely wrong.

Or, as you mentioned in another post, you're stressed out over the "John
Bokma Harassment" nonsense, and a little too quick on the trigger. It's
perfectly understandable - I'd probably be acting the same or worse in
your situation. Certainly no apology is needed.

Some friendly advice: Take the weekend off. I think you might need it. And
then on Monday we can argue about how to *pronounce* Jürgen, now that we
agree on how to spell it. :-D

sherm--
 
J

John Bokma

Sherm Pendley said:
I did, but I wasn't referring to your correction of that, I was
referring to what looked to me like a correction of my spelling of
Jürgen.

No, no, apologies for the confusion.
That assumption wasn't clear in the message I "creatively" :-D quoted
above. To me it looks like you're telling me there's an umlaut in
Jürgen.

Yes, you deleted the rest, and then it indeed looks odd. Note that
English is my second language, so I might be able to write gibberish.
Or, as you mentioned in another post, you're stressed out over the
"John Bokma Harassment" nonsense, and a little too quick on the
trigger. It's perfectly understandable - I'd probably be acting the
same or worse in your situation. Certainly no apology is needed.

Thanks :)
Some friendly advice: Take the weekend off. I think you might need it.

I already took Wednesday off (not really related with the Harassment
thing, but it was a good timing, swiming in a lake near to a waterfall
is quite relaxing).
And then on Monday we can argue about how to *pronounce* Jürgen, now
that we agree on how to spell it. :-D

Ha ha ha. I am afraid that my German accent is quite horrible.
 
T

Tad McClellan

John Bokma said:
English is my second language, so I might be able to write gibberish.


English is my first language and I have shown (with distressing
frequency) that I am able to write gibberish too...


.... so don't be thinking you're special or anything! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,188
Messages
2,571,002
Members
47,591
Latest member
WoodrowBut

Latest Threads

Top