473,657 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

THE integer (or parseInt) inaccuracy all should know about

Regarding
http://mynichecomputing.com/digitallearning/yourOwn.htm
and how to make it fail when it should not with an integer OR
parseInt to integer conversion problem.
THE real problem IS is that simply doing the following ,
tempx = parseInt(((fpss Array[i][j]).toString()).s ubstring((m*3),
(m*3)+3));
does NOT work.

This show show an integer problem (or parseInt problem) that there
SHOULDN'T
BE.

I am truly embarrassed for previously not having set up the proper
experiment
which does show
an integer problem and do apologize to the group. The experiment NOW
though has been indicated and it there to show something that shows
an
unexpected integer (OR parseInt) problem.

IN THE TXT FILE MENTIONED AT THE TOP OF THE POST:
One must change that line, not only omitting the .9 but also
omitting the intermediate parseFloat conversion to see the problem I
saw.

THUS, If one changes the line
tempx = parseInt(parseF loat(((fpssArra y[i]
[j]).toString()).s ubstring((m*3), (m*3)+3)) + .9);
TO
tempx = parseInt(((fpss Array[i][j]).toString()).s ubstring((m*3),
(m*3)+3));

THE INTEGER PROBLEM OR PARSEINT PROBLEM DOES OCCUR.
I just tested it and
verified it.

I have only proprietary scoring systems. SO: You simply have to make
your own
(as described). Sorry.

In summary:
There is an integer (or parseInt) problem which needs to be known
about.
I had forgotten 2 changes were involved in fixing the problem. How
to
recreate the problem has now been clearly indicated.
Aug 19 '08 #1
6 1495
P.S. Addressing the division by three in the program mentioned
by Lasse Reichstein Nielsen in the other "corrupted thread" as a
possible problem
It is here:
m<Math.floor((( fpssArray[i][j].toString()).le ngth)/3);

If indeed m were COMPARED DIRECTLY TO a value divided by three, I
could imagine a problem. But, m is compare only to an integer,
from Math.floor(...) . Thus no comparison with a non-integer occurs.

There is no explanation for the scoring miscounts in the
experiment, as I have now correctly described it, except
a parseInt or integer problem (in either case, what I would
call an integer inaccuracy problem).
On Aug 19, 5:51*pm, lorlarz <lorl...@gmail. comwrote:
Regardinghttp://mynichecomputin g.com/digitallearning/yourOwn.htm
and how to make it fail when it should not with an integer OR
parseInt to integer conversion problem.

THE real problem IS *is that simply doing the following ,
tempx = parseInt(((fpss Array[i][j]).toString()).s ubstring((m*3),
(m*3)+3));
does NOT work.

This show show an integer problem (or parseInt problem) that there
SHOULDN'T
BE.

*I am truly embarrassed for previously not having set up the proper
experiment
which does show
an integer problem and do apologize to the group. *The experiment NOW
though has been indicated and it there to show something that shows
an
unexpected integer (OR parseInt) problem.

IN THE TXT FILE MENTIONED AT THE TOP OF THE POST:
One must change that line, not only omitting the .9 but also
omitting the intermediate parseFloat conversion to see the problem I
saw.

THUS, If one changes the line
tempx = parseInt(parseF loat(((fpssArra y[i]
[j]).toString()).s ubstring((m*3), (m*3)+3)) + .9);
TO
tempx = parseInt(((fpss Array[i][j]).toString()).s ubstring((m*3),
(m*3)+3));

THE INTEGER PROBLEM OR PARSEINT PROBLEM DOES OCCUR.
*I just tested it and
verified it.

I have only proprietary scoring systems. *SO: You simply have to make
your own
(as described). *Sorry.

In summary:
There is an integer (or parseInt) problem which needs to be known
about.
I had forgotten 2 changes were involved in fixing the problem. *How
to
recreate the problem has now been clearly indicated.
Aug 19 '08 #2
A quick P.P.S.

Having the line like the following:
tempx = parseInt(parseF loat(((fpssArra y[i]
[j]).toString()).s ubstring((m*3), (m*3)+3)) + .9);

is the solution to the integer or parseInt problem.
(That is why you have to change it in a couple of ways to do
the experiment to see the integer problem).

In the other thread:
The parseInt in the line of code was confounding (messing up) the
experiment which SHOWS the integer or parseInt inaccuracy
or error (and *only in _that sense_* is this above line
a "problem" -- i.e. it corrupted the experiment showing the
problem).

Again THIS LINE,

tempx = parseInt(parseF loat(((fpssArra y[i]
[j]).toString()).s ubstring((m*3), (m*3)+3)) + .9);

ALL SHOULD KNOW IS THE **SOLUTION** and the way to
yield correct instead of incorrect RESULTS.

Again, The line that yields an unexpected problem is:

tempx = parseInt(((fpss Array[i][j]).toString()).s ubstring((m*3),
(m*3)+3));

No parseFloat there and nothing is being compared to any float!!

This has yet to be explained.
Aug 19 '08 #3
On Aug 19, 6:48*pm, lorlarz <lorl...@gmail. comwrote:
A quick P.P.S.

Having the line like the following:
tempx = parseInt(parseF loat(((fpssArra y[i]
[j]).toString()).s ubstring((m*3), (m*3)+3)) + .9);

is the solution to the integer or parseInt problem.
(That is why you have to change it in a couple of ways to do
*the experiment to see the integer problem).

In the other thread:
The parseInt in the line of code was confounding (messing up) the
experiment which SHOWS the integer or parseInt inaccuracy
or error (and *only in _that sense_* is this above line
a "problem" -- i.e. it corrupted the experiment showing the
problem).

Again *THIS LINE,

tempx = parseInt(parseF loat(((fpssArra y[i]
[j]).toString()).s ubstring((m*3), (m*3)+3)) + .9);

ALL SHOULD KNOW IS THE **SOLUTION** and the way to
yield correct instead of incorrect RESULTS.

Again, The line that yields an unexpected problem is:

tempx = parseInt(((fpss Array[i][j]).toString()).s ubstring((m*3),
(m*3)+3));

No parseFloat there and nothing is being compared to any float!!

This has yet to be explained.
Ok. I will do the work for all you lazy rude thankless people:

First let's use the good (the fixed) version with the
tempx = parseInt(parseF loat(((fpssArra y[i]
[j]).toString()).s ubstring((m*3), (m*3)+3)) + .9);

line:

Paste in Sample scoring system:
http://mynichecomputing.com/testIntP...mplScoring.txt
(paste it in http://mynichecomputing.com/testIntProb/oldTest.html
with the cursor sitting right after the last zero)

Click DoIt Button.

Paste the true answer set into that same textarea:
http://mynichecomputing.com/testIntProb/Tans.txt (cursor right after
the last
character)

Click DoIt button again and observe results.

--------------
--------------
NOW, LET'S DO IT WITH THE BAD VERSION: This is the version
with the
tempx = parseInt(((fpss Array[i][j]).toString()).s ubstring((m*3),
(m*3)+3));

line: http://mynichecomputing.com/testIntProb/testNew.html

Paste in Sample scoring system:
http://mynichecomputing.com/testIntP...mplScoring.txt
(paste it in http://mynichecomputing.com/testIntProb/testNew.html
with the cursor sitting right after the last zero)

Click DoIt Button

Paste the true answer set into that same textarea:
http://mynichecomputing.com/testIntProb/Tans.txt (cursor right after
the last
character)

Click DoIt button again and observe results.

--------------
THERE, that's your proof. EXPLAIN IT.



Aug 20 '08 #4
lorlarz wrote:
<snip>
THERE, that's your proof. EXPLAIN IT.

As you have a copy of javascript: The Good Parts, look up - parseInt -
in the index (it is page 104: in the "Awful Parts" appendix) and read
the second paragraph. This is also covered in the group's FAQ.

Richard.

Aug 20 '08 #5
On Aug 20, 3:19*am, "Richard Cornford" <Rich...@litote s.demon.co.uk>
wrote:
lorlarz wrote:

<snip>
THERE, that's your proof. *EXPLAIN *IT.

As you have a copy of javascript: The Good Parts, look up - parseInt -
in the index (it is page 104: in the "Awful Parts" appendix) and read
the second paragraph. This is also covered in the group's FAQ.

Richard.
Fortunately, I have the book and did read it. I guess I did not
process
the appendices thoroughly (or apply all they said to all my programs
that
are years old). I reread page 104.

Indeed, if you change the key line in
http://mynichecomputing.com/testIntProb/testNew.html
to include the optional radix paramater
(the base) (and I want base 10), the problem seems to disappear:

So making the key line read,
tempx = parseInt(((fpss Array[i][j]).toString()).s ubstring((m*3),
(m*3)+3),10);
seems to work.

On first run, that appears to fix things without the workaround I
previously used.

Thanks for your information.
Aug 20 '08 #6
On Aug 20, 3:19*am, "Richard Cornford" <Rich...@litote s.demon.co.uk>
wrote:
lorlarz wrote:

<snip>
THERE, that's your proof. *EXPLAIN *IT.

As you have a copy of javascript: The Good Parts, look up - parseInt -
in the index (it is page 104: in the "Awful Parts" appendix) and read
the second paragraph. This is also covered in the group's FAQ.

Richard.
Not wanting to cast any aspersions on my favorite programming
language, let me
add as a P.S. that the "problem" I had was actually related to an
understandable
FEATURE of the parseInt function. So, this is not like an error,
_except_ in the
sense that the radix (base) argument has to be KNOWN to be required if
any leading
zeros might be involved.

The base is NOT optional in cases where there may be leading zeros
because of "features" of the parseInt function,
seeing things as octal if they begin with zero and then not
recognizing the
digits 8 and 9.

Thanks again. Perhaps all this was not a total waste of time for
those
who were thoroughly knowledgeable. I do supply an illustration of
the
problem which might "bring it home" for some in the future.

Aug 20 '08 #7

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

Similar topics

3
7209
by: S C A | last post by:
Dear All: I'm not sure if this is even possible but does anyone know about using ActiveX controls (a Microsoft-specific technology) in Java? I am having a heck of a time finding some similar functionality in Java provided by some controls (ActiveX) and I was wondering if I can manipulate them using Java? Thanks in advance, Carl
3
4626
by: jose isaias cabrera | last post by:
Greetings! I've looked through the internet (not long, though) but I have not been able to find a python translation to buffer = (byte)Integer.parseInt(string,16); Has anyone ported any java programs to python and has translated this? any help would be greatly appreciated.
2
2051
by: Lindon | last post by:
Until now I've been programming straight console apps, and all I've been doing to compile is a simple 'gcc file1.cpp file2.cpp ....'. What more is there to know about the compiler? I'd like to know exactly what happens during each step. Is the compilation of dll's (and corresponding libs on *nix) possible with only the compiler and no platform specifc libraries (like windows.h)? What am I missing out on? thanks, lin
9
54172
by: Henrik | last post by:
In Java you can write something like this. Does anyone know how to do this in javascript? "byte b=Integer.parseInt(int value or String).byteValue;"
7
1286
by: Micheal | last post by:
Hi, I want to know about news groups of visual studio.net 2005 . regards micheal
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8612
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4171
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.