473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Negative Numbers in Mozilla

Hi,

I have a bit of code which draws a chart up or down from the centre line
(zero).

When I have negative numbers in MSIE it displays fine and in Mozila it
doesn't draw at all.

Positve numbers draw without problems.

Anybody any ideas.

TIA
This calls the function to draw

histchart(-5.3,3)

This is my external jsfile

colr = new Array()
colr[3] ='#FEC9BC'
colr[5] ='#OOCC33'
colr[10] ='#3780C8'

function histchart(change,col)
{
colour = colr[col]
change = parseInt(10*parseFloat(change))/10

if(change<0)
{
scale = 10
document.write("<table width='100%' height='100%' border='0'
cellpadding='0' cellspacing='0'><tr><td height='70%' align='center'
valign='bottom' class=p7a>" + change +"</td></tr><tr><td height='1'
bgcolor='#000000'></td></tr><tr><td height='50%' valign='top'><div
align='center'><table width='15' height=" + parseInt(scale*Math.abs(change))
+ "% border='0' cellpadding='0' cellspacing='0' bgcolor=" + colour +
"><tr><td></td></tr></table></div></td></tr></table>")

}
else
{
scale = 5
document.write("<table width='100%' height='100%' border='0'
cellpadding='0' cellspacing='0'><tr><td height='70%' align='center'
valign='bottom'><table width='15' height='100%' border='0' cellpadding='0'
cellspacing='0'><tr><td></td></tr><tr><td height=" + parseInt(scale*change)
+ "% bgcolor=" + colour + "></td></tr></table></td></tr><tr><td height='1'
bgcolor='#000000'></td></tr><tr><td height='50%' valign='top'><div
align='center' class=p7a>+" + change + "</div></td></tr></table>")

}
}
Jul 23 '05 #1
1 1424
Lee
Iain West said:

Hi,

I have a bit of code which draws a chart up or down from the centre line
(zero).

When I have negative numbers in MSIE it displays fine and in Mozila it
doesn't draw at all.

scale = 10
document.write("<table width='100%' height='100%' border='0'
cellpadding='0' cellspacing='0'><tr><td height='70%' align='center'
valign='bottom' class=p7a>" + change +"</td></tr><tr><td height='1'
bgcolor='#000000'></td></tr><tr><td height='50%' valign='top'><div
align='center'><table width='15' height=" + parseInt(scale*Math.abs(change))
+ "% border='0' cellpadding='0' cellspacing='0' bgcolor=" + colour +
"><tr><td></td></tr></table></div></td></tr></table>")


You shouldn't be using parseInt with numerical arguments.

It takes a string as an argument, so it's converting the number to
a string and then parsing the integer value out of that string.
Netscape converts numbers between (-1,1) to strings beginning
with a decimal point. Such strings cannot be parsed by parseInt.

Use Math.round() or Math.floor(), depending on your needs.

Jul 23 '05 #2

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

Similar topics

7
by: pj | last post by:
Why does M$ Query Analyzer display all numbers as positive, no matter whether they are truly positive or negative ? I am having to cast each column to varchar to find out if there are any...
5
by: Subrahmanyam Arya | last post by:
Hi Folks , I am trying to solve the problem of reading the numbers correctly from a serial line into an intel pentium processor machine . I am reading 1 byte and 2byte data both positive...
15
by: jaks.maths | last post by:
How to convert negative integer to hexadecimal or octal number? Ex: -568 What is the equivalent hexadecimal and octal number??
20
by: Casey | last post by:
Is there an easy way to use getopt and still allow negative numbers as args? I can easily write a workaround (pre-process the tail end of the arguments, stripping off any non-options including...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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...

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.