473,671 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Negative double not stored correctly

Hi All,

I've defined a table (m) with an double field (bedrag) in it and when
I execute the next statement:

INSERT INTO m (bedrag) VALUES('-7000,00');

the value get stored correctly.

I've written a PHP-script which does the following:

$SQL="INSERT INTO m (getal) VALUES('$bedrag ')";
$res=mysql_quer y($SQL);
echo "SQL = ".$SQL."<br >";

When I look at the display from the echo statement it looks like:

SQL = INSERT INTO m (getal) VALUES('-7.000,00')

So that looks OK. But when I do a SELECT * FROM m; in MySQL the stored
value is -7,00 instead of -7000,00. I've defined the bedrag field as
DOUBLE(10,2) so that should not be a problem.
I'm using PHP 4.3.2 and MySQL 4.0.20a.

Can anyone tell me what I'm doing wrong here?

Richard.
Jul 20 '05 #1
2 4932
"Richard van Denzel" wrote:
Hi All,

I’ve defined a table (m) with an double field (bedrag) in it and
when
I execute the next statement:

INSERT INTO m (bedrag) VALUES(’-7000,00’);

the value get stored correctly.

I’ve written a PHP-script which does the following:

$SQL="INSERT INTO m (getal) VALUES(’$bedrag ’)";
$res=mysql_quer y($SQL);
echo "SQL = ".$SQL."<br >";

When I look at the display from the echo statement it looks like:

SQL = INSERT INTO m (getal) VALUES(’-7.000,00’)

So that looks OK. But when I do a SELECT * FROM m; in MySQL the stored value is -7,00 instead of -7000,00. I’ve defined the bedrag
field as
DOUBLE(10,2) so that should not be a problem.
I’m using PHP 4.3.2 and MySQL 4.0.20a.

Can anyone tell me what I’m doing wrong here?

Richard.


What’s "," in 7.000,00. Can you try removing the "," and see
what happens?

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/mySQL-Negati...ict136793.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=457416
Jul 20 '05 #2
Richard van Denzel wrote:
I've defined a table (m) with an double field (bedrag) in it and when
I execute the next statement:

INSERT INTO m (bedrag) VALUES('-7000,00');


As far as I can tell from the documentation, MySQL does not support the
German-style numeric format. You must use "." as the decimal point, and
no thousands separator is supported.

Perhaps one could write a UDF to parse strings in the German numeric
format, and convert them to decimal values before inserting them.
I don't know how to do this, but I imagine it would be possible.

Regards,
Bill K.
Jul 20 '05 #3

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

Similar topics

0
1890
by: Danny Winslow | last post by:
I get an unexpected result when I add two negative numbers in PHP on SPARC/Solaris 8. The same program works fine on Intel/Linux. I'm using PHP 4.3.1 on both systems. Here is my program, test.php. <?php $a = 0x81234567; $b = 0xF0000002; printx($a, $b);
2
631
by: Richard van Denzel | last post by:
Hi All, I've defined a table (m) with an double field (bedrag) in it and when I execute the next statement: INSERT INTO m (bedrag) VALUES('-7000,00'); the value get stored correctly. I've written a PHP-script which does the following:
4
2141
by: Charles A. Lackman | last post by:
Hello, I have some textboxes that are doing addition: Dim AString As Double AString = Convert.ToDouble(TextBox1.Text) - Convert.To(DoubleTextBox2.Text) TextBox3.Text = AString.ToString("#,##0.00;(#,##0.00);0.00") When the result is negative it is displayed as "(46)" or whatever the value is.
16
5069
by: JKop | last post by:
Take a class like the following: class Finger { public: double length; }
5
6114
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 and negative quantities . Can any one tell me what are the things i should bear in mind .
11
2385
by: John | last post by:
Hi, I encountered a strange problem while debugging C code for a Windows-based application in LabWindows CVI V5.5, which led me to write the test code below. I tried this code with a different compiler and got the same erroneous result on two different PCs (with OS Win98 & Win98SE), so it appears to be a problem with ANSI C. I thought that negative double variables could be compared as easily and *reliably* as integers, but apparently...
44
16323
by: Daniel | last post by:
I am grappling with the idea of double.Epsilon. I have written the following test: public void FuzzyDivisionTest() { double a = 0.33333d; double b = 1d / 3d; Assert.IsFalse(a == b, "Built-in == operator should not be
11
3704
by: Ole Nielsby | last post by:
First, sorry if this is off-topic, not strictly being a C++ issue. I could not find a ng on numerics or serialization and I figure this ng is the closest I can get. Now the question: I want to serialize doubles in human-readable decimal form and be sure I get the exact same binary values when I read them back. (Right now, I don't care about NaN, infinities etc.)
8
2268
by: SK | last post by:
Hello all, I need to pass a string to a sql procedure in this fashion <DateParam> <BeginDate="2007-01-25" BeginTime="08:30 AM" EndTime="09:45AM"/> </DateParam> If you notice the date and time are enclosed in double quotes. How do I achieve this in C# I tried using the escape sequence "\"", but the \ also gets included and the stored procedure fails.
1
8605
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8676
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...
0
7445
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6237
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
5703
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
4227
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...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
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
1816
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.