hi group -
I had this in a function - so I've just moved this out of the function
for readabilty.
Can someone please tell me WHY does this not return the result of :
n1 times n2
As I said - I took it out of the function just for readability :
In my php file :
$number_percent ="25";
echo "history['order_total'] is ".$history['order_total']."<br />";
echo "number_per cent is ".$number_perce nt."<br />";
$total=(($histo ry['order_total'])*$number_perce nt);
echo "total is ".$total."< br />";
And here is the output in the browser :
history['order_total'] is $241.47
number_percent is 25
total is 0
WHY ? Any advice or pointers would be much appreciated!
Feb 7 '07
13 3337
One <da**********@g mail.comwrote:
Input :
echo "history['order_total'] is ".$history['order_total']."<br />";
$removeit=str_r eplace('$' ,'', $history['order_total']);
echo $removeit;
$floatandremove = floatval($remov eit);
echo "<br />floatandremo ve is ".$floatandremo ve;
exit;
Output :
history['order_total'] is $241.47
241.47
floatandremove is 0
There must be something else going on with your currency string.
Please use this on that string, and report it's results back to us:
echo preg_replace('/(.)/se','"[".ord("$1") ."]"',$history['order_total']);
--
Rik Wasmus
On Feb 8, 2:01 pm, Rik <luiheidsgoe... @hotmail.comwro te:
One <david.hun...@g mail.comwrote:
Input :
echo "history['order_total'] is ".$history['order_total']."<br />";
$removeit=str_r eplace('$' ,'', $history['order_total']);
echo $removeit;
$floatandremove = floatval($remov eit);
echo "<br />floatandremo ve is ".$floatandremo ve;
exit;
Output :
history['order_total'] is $241.47
241.47
floatandremove is 0
There must be something else going on with your currency string.
Please use this on that string, and report it's results back to us:
echo preg_replace('/(.)/se','"[".ord("$1") ."]"',$history['order_total']);
--
Rik Wasmus
Thanks again Rik - here you go :
Input :
echo "history['order_total'] is ".$history['order_total']."<br />";
echo preg_replace('/(.)/se','"[".ord("$1") ."]"',
$history['order_total']);
exit;
Output :
history['order_total'] is $241.47
[60][98][62][36][50][52][49][46][52][55][60][47][98][62]
One wrote:
history['order_total'] is $241.47
[60][98][62][36][50][52][49][46][52][55][60][47][98][62]
$history['order_total'] contains '<b>$241.47</b>'. This is not a number.
$history['order_total'] = (float)preg_rep lace('/[^0-9\.]/', '',
strip_tags($his tory['order_total']));
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/CSS/Javascript/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there!
On Feb 9, 5:51 am, Toby A Inkster <usenet200...@t obyinkster.co.u k>
wrote:
One wrote:
history['order_total'] is $241.47
[60][98][62][36][50][52][49][46][52][55][60][47][98][62]
$history['order_total'] contains '<b>$241.47</b>'. This is not a number.
$history['order_total'] = (float)preg_rep lace('/[^0-9\.]/', '',
strip_tags($his tory['order_total']));
Mr. Toby!
You da man - thanks very much!
Thank you also to Rik and Jerry for taking the time to resolve this
issue. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Radioactive Man |
last post by:
In python 2.3 (IDLE 1.0.3) running under windows 95, I get the
following types of errors whenever I do simple arithmetic:
1st example:
>>> 12.10 + 8.30
20.399999999999999
>>> 1.1 - 0.2
0.90000000000000013
|
by: cwdjrxyz |
last post by:
Javascript has a very small math function list. However there is no
reason that this list can not be extended greatly. Speed is not an
issue, unless you nest complicated calculations several levels deep. In
that case you need much more ram than a PC has to store functions
calculated in loops so that you do not have to recalculate every time
you cycle through the nest of loops. Using a HD for storage to extend
ram is much too slow for many...
|
by: Ralf Hildebrandt |
last post by:
Hi all!
First of all: I am a C-newbie.
I have noticed a "strange" behavior with the standart integer
multiplication. The code is:
void main(void)
|
by: ccosse |
last post by:
Hello,
just to announce a new version of Multiplication Station available at
http://www.asymptopia.org. Multiplication Station is an OpenSource math
education game. It will teach your child basic maths, guaranteed. It is
multi-user, has a countdown timer and tracks high scores. All
parameters are configurable through the simple admin interface. Please
visit to download a copy today. Certified GPL OpenSource.
Asymptopia Software |...
|
by: Gregory Pietsch |
last post by:
I'm writing a portable implementation of the C standard library for
http://www.clc-wiki.net and I was wondering if someone could check the
functions in math.h for sanity/portability/whatever. I'm almost halfway
through writing the over 200 functions needed to implement C99's
version of math.h, and I would like to have some feedback and/or expert
advice on my implementations.
Sincerely, Gregory Pietsch
| |
by: VijaKhara |
last post by:
Hi all,
Is there any method which can implememt the matrix multiplication
faster than using the formula as we often do by hand?
I am writing the following code and my matrice: one is 3x40000 and the
other one 40000x3.
the program runs too slow:
/*multiply two matrice: xyz_trans * xyz , the output is w 3x3*/
|
by: =?Utf-8?B?UmVuZQ==?= |
last post by:
Hello everyone
I have a problem with Math.Round, it´s ocurring some strange:
Math.Round(12.985) = 12.98, it´s wrong. It should be: 12.99
Why?? What is the problem?
Help ME !!!!
|
by: crazygrey |
last post by:
Hello, I'm a newbie to C++ so excuse me if my question was trivial but
it is important to me.
I'm implementing a simple code to find the forward kinematics of a
robot:
#include "stdafx.h"
#include<iostream>
#include<iomanip>
#include<fstream>
#include"math.h"
|
by: Sozos |
last post by:
Hi guys. I have a problem with writing the base case for the following matrix multiplication function I have implemented. Please help.
#define index(i,j,power) (((i)<<(power))+(j))
void recMultiply(int i, int j, float a, int k, int l, float b, int x, int y, float c, int s);
int i, j, k, s, matrixsize, blocksize, jj, kk, power, bsize;
float sum, maxr, total=0.0, startmult, finishmult, multtime;
float* A = NULL;
float* B = NULL;
|
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: 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,...
| |
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: 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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |