Hello,
I wanted to create a currency translator with PHP.
The code looks like this:
<?php
$faktor=2.95583 ; // a double
$dm = $euro * $faktor; // $euro is a double variable with the
original value
// $dm is a double variable
echo $dm; // prints 10 when $euro is 5
?>
all varables are double, I checked this with the gettype() function
The calculation seems to take only the integers and cuttig off the .9
before calculating
Another example:
echo 5.5*2.2; // prints 10, should be about 11
what can I do if I want to multily doubles to get the correct answer?
I hope anyone can help me!
thanks in advance for your help!
christine 4 2257 ch*******@hutt-edv.de (christine) wrote: $faktor=2.95583 ; // a double $dm = $euro * $faktor; // $euro is a double variable with the original value // $dm is a double variable
echo $dm; // prints 10 when $euro is 5
No, it prints 14.77915 when $euro is 5
Another example: echo 5.5*2.2; // prints 10, should be about 11
No, it prints 12.1, and that's exactly what it should do.
JOn
No it worked for me ...
Savut
"christine" <ch*******@hu tt-edv.de> wrote in message
news:f1******** *************** ***@posting.goo gle.com... Hello,
I wanted to create a currency translator with PHP.
The code looks like this: <?php
$faktor=2.95583 ; // a double $dm = $euro * $faktor; // $euro is a double variable with the original value // $dm is a double variable
echo $dm; // prints 10 when $euro is 5
?>
all varables are double, I checked this with the gettype() function The calculation seems to take only the integers and cuttig off the .9 before calculating
Another example: echo 5.5*2.2; // prints 10, should be about 11
what can I do if I want to multily doubles to get the correct answer?
I hope anyone can help me! thanks in advance for your help!
christine
Jon Kraft wrote: ch*******@hutt-edv.de (christine) wrote:
$faktor=2.95583 ; // a double $dm = $euro * $faktor; // $euro is a double variable with the original value // $dm is a double variable
echo $dm; // prints 10 when $euro is 5
No, it prints 14.77915 when $euro is 5
Another example: echo 5.5*2.2; // prints 10, should be about 11
No, it prints 12.1, and that's exactly what it should do.
JOn
$ cat xx.php
<?php
ini_set('precis ion', '2');
$euro = 5;
$faktor = 2.95583;
$dm = $euro * $faktor;
echo "--------\n$dm\n";
echo 5.5*2.2, "\n";
?>
$ php xx.php
--------
15
12
Check your php.ini !
--
--= my mail address only accepts =--
--= Content-Type: text/plain =--
--= Size below 10K =-- ch*******@hutt-edv.de (christine) wrote in message news:<f1******* *************** ****@posting.go ogle.com>... Hello,
I wanted to create a currency translator with PHP.
The code looks like this: <?php
$faktor=2.95583 ; // a double $dm = $euro * $faktor; // $euro is a double variable with the original value // $dm is a double variable
echo $dm; // prints 10 when $euro is 5
?>
all varables are double, I checked this with the gettype() function The calculation seems to take only the integers and cuttig off the .9 before calculating
Another example: echo 5.5*2.2; // prints 10, should be about 11
I installed PHP 4.3.4 instead of PHP 4.0.0 and now it works.
Thanks for your answers!
christine This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: For example John Smith |
last post by:
I have the following issue:
I read lines of information from a log file. Each line is identified by an
ID number.
Due to nature of the logging process it is possible blocks are logged more
than once, but in these cases the IDs will be similar.
In my PHP script I temporarily store all read ID numbers in an array. When
done reading I want to sort the array and then loop through it to check for
doubles. Right now all I am interested in is...
|
by: Phil McKraken |
last post by:
I am having a problem putting together a shopping cart with the below
script. Everything displays fine, adds totals fine, and works perfect
EXCEPT if you choose the 9.95 item #5 BY ITSELF the total displayed is
$9.94 ! If you add ANYTHING else the total is correct, 9.95 plus
whatever you add. That is the only price in these samples that is
doing that. All the others display properly. If you change the 9.95 to
ANY other number it displays...
|
by: Johm |
last post by:
I have a very complicated problem.I have a function that checks
whether the cartons in the warehouse,which are branch0, are greater
than the cartons ordered. Which means that
If branch < cartons then
exit function
The function works great if the cartons are not opened.But when one
carton is opened, and one piece from the carton is sold, then the
number of the cartons in the warehouse is with 1 less, since one
carton
|
by: John R. Delaney |
last post by:
I am running in debugging mode after a clean C++ compilation under .NET 2003. In a BIG loop (controlled many levels up in the call stack), I open a file with fopen using the "a" option. Then I write 23 doubles to it with fwrite, one call for each double. Then I close the file using fclose. After three times around the loop in the debugger, I stop the program (using "Stop debugging"). That is writing 552 bytes.
The resulting file's properties...
|
by: julien |
last post by:
Hi, I am using Sybase 12.5 dataserver and ASP.NET
I am calling a stored procedure from my asp.net page, in this stored
procedure, I have 2 float fields that are returned. One is directly
taken from one float column of a table, and the other one is a
substraction of 2 float columns of a table. The first field is all the
time ok, whereas the calculated field is almost all the time wrong,
that is it returns things like :
1,332294 - 1,334709...
| |
by: pelletier.thomas |
last post by:
Hello everybody. I'm trying to code a very little OS.
But I have a problem with the keyboard input:
It show thechar + "~" :s
Can you help me ?
The source is there : http://thonix.tuxfamily.org/pub/0.0.1/src/
|
by: Vijaykumar Dave |
last post by:
I have a program for base X power N as under. The problem is that when
the range specified in loop is given it works well, but when any
character is pressed, it goes to infinite loop.
Second problem is it works fine for smaller value of X or N but not
for higher say base 15 power 20. How can I get true value displayed
with such higher base or power.?
Can any one help me to correct this program putting proper loop and
for high value...
|
by: EJSpin |
last post by:
Hey guys, I have put together a class called Mu
class Mu
{
private:
double **s;
int velocity,numbers;
double sPeak,muPeak,mu1;
double a1,b1,c1,u_s;
|
by: yxxxxy |
last post by:
Hi, this is a part of my program code.
i want to ask two questions.
int time;
float rate;
float salary;
printf("Enter # of hours worked (-1 to end):");
scanf("%d",&time);
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |