473,473 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

What does this script do?

Wow
var abc=64; document.write(abc^2);
then it display 66

var abc=66; document.write(abc^2);
then it displays 64

What is the ^2 ? 66^2=4365
not 64. even I mod 128 or 256, I got 4, not 64
Jul 23 '05 #1
6 1181
> What is the ^2 ?

^ is raise to the power of.

64^2 is the same as 64*64 which = 4365

2^8 = 256 (2*2*2*2*2*2*2*2)
Jul 23 '05 #2
On Sun, 25 Jul 2004 08:11:22 GMT, Andy wrote:
What is the ^2 ? 66^2=4365

No.. 4356
^ is raise to the power of.

64^2 is the same as 64*64 which = 4365


and ..4096

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #3
"Andrew Thompson" wrote
No.. 4356 and and ..4096


Why the hell did I type the wrong answers in? It is plainly 4356 and 4096
so why on earth did I type 4365 twice?

Going mad.

Jul 23 '05 #4
"Wow" <a@alexa.com> writes:
var abc=64; document.write(abc^2);
then it display 66

var abc=66; document.write(abc^2);
then it displays 64

What is the ^2 ?
Read some Javascript manual. E.g.:
<URL:http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/ops.html>

The "^" operator is the bitwise exclusive or operator. So, writing
62 and 2 as binary,
01000000 = 64
^ 00000010 = 2
--------
= 01000010 = 66
66^2=4365


That would be an exponetiation operator. There isn't one in Javascript,
you must use Math.pow(66,2) for that.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #5
On Sun, 25 Jul 2004 09:50:46 GMT, Andy wrote:
Going mad.


(chuckles) Notwithstanding of course, L.R.N.s
comment they were bitwise operators ..oops!

I was wondering vaguely whether the OP
was refering to an exponent or 'some
...bit operation' in that expression, but
noted the square of an even number should
be even.., then when you requoted the same
number as the square of 64, I jumped in and
the rest, as they say, is history.

Wait 24hrs, read back on it, and be amused. ;-)

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
Jul 23 '05 #6
Wow
> > var abc=64; document.write(abc^2);
then it display 66

var abc=66; document.write(abc^2);
then it displays 64

What is the ^2 ?
Read some Javascript manual. E.g.:

<URL:http://devedge.netscape.com/library/...pt/1.3/referen
ce/ops.html>
The "^" operator is the bitwise exclusive or operator. So, writing
62 and 2 as binary,
01000000 = 64
^ 00000010 = 2
--------
= 01000010 = 66
66^2=4365


That would be an exponetiation operator. There isn't one in Javascript,
you must use Math.pow(66,2) for that.


YOU ARE THE MAN!!!!
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Al Davis | last post by:
Note: I tried cross-posting this message to several newsgoups, including comp.lang.perl.misc, c.l.p.moderated, comp.infosystems.www.authoring.cgi, comp.lang.javascript and comp.lang.php. Nothing...
4
by: F. Da Costa | last post by:
Hi, I was wondering whether someone could enlighten me as to the reason why the slice does not work in IE when the arr is passed in properly. Checked the values in the srcArr and they are...
5
by: Emmanuel Papillon | last post by:
Hello. I've got a page with sound through a swf file, working with an animation with preloaded JPEG files (animated through use of setTimeout). I'm preloading the JPEG files through Javascript...
14
by: Frances Del Rio | last post by:
if (parent.frames.main.location == 'mediaselect.html') { I have a very simple frameset, name of frame where I'm checking is 'main'... why is this not working? I mean this is correct syntax,...
17
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
8
by: johnsonholding | last post by:
Here is the code for a pop-up window that works in Firefox and not in IE - I get a java error or something, Here is the code : </script> <SCRIPT language="JavaScript"...
13
by: Fro | last post by:
Hi, my site allows to upload images. For that reasons I have created a directory which have "drwxrwxrwx"-permission. I.e. everybody can write in that directory. I understand that it is not save,...
34
by: Jorge | last post by:
Why is it listed here : http://www.crockford.com/javascript/recommend.html under "deprecation" ? Without it, how is an anonymous function() going to call itself (recursively) ? I use to...
11
Dormilich
by: Dormilich | last post by:
Lately I have seen so much awful HTML, that I like to show what a HTML document should look like, regarding the requirements from the W3C. the absolute minimum is defined as: or expressed in...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.