This is true: "2-3"==1
But "1-2"==1 is not true
Why ? 5 1065 gr*****@reenie. org wrote:
This is true: "2-3"==1
But "1-2"==1 is not true
Why ?
RTFM on type juggling. You may not be doing a comparison between integers or
between strings. Force type casting where appropiate.
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
MSN:i_********* *************** *@hotmail.com
Jabber:iv****** ***@jabber.org ; iv*********@kde talk.net
On Dec 31, 1:24 pm, Iván Sánchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.orgwrote:
grou...@reenie. org wrote:
This is true: "2-3"==1
But "1-2"==1 is not true
Why ?
RTFM on type juggling. You may not be doing a comparison between integers or
between strings. Force type casting where appropiate.
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
MSN:i_eat_s_p_a _m_for_breakf.. .@hotmail.com
Jabber:ivansanc ...@jabber.org ; ivansanc...@kde talk.net
Yes, I read that already. I know how to make it consistent with type
casting, but that is not my question.
In both cases, it is a comparison between a string and an integer.
The Manual says:
If the string starts with valid numeric data, this will be the value
used. Otherwise, the value will be 0 (zero).
Bot strings start with valid numeric data, so I still want to know why
one is true and the other is not. gr*****@reenie. org wrote:
This is true: "2-3"==1
But "1-2"==1 is not true
Why ?
<?php
var_dump("2-3"==1);
var_dump("1-2"==1);
?>
Output:
bool(false)
bool(true)
Why? "2-3" evaluates to 2, "1-2" evaluates to 1. 2!=1 therefore the
first statement is false, the second one is true because 1==1
--
Posted via a free Usenet account from http://www.teranews.com
On Dec 31, 2:40 pm, Justin Koivisto <justin.koivi.. .@gmail.comwrot e:
grou...@reenie. org wrote:
This is true: "2-3"==1
But "1-2"==1 is not true
Why ?
<?php
var_dump("2-3"==1);
var_dump("1-2"==1);
?>
Output:
bool(false)
bool(true)
Why? "2-3" evaluates to 2, "1-2" evaluates to 1. 2!=1 therefore the
first statement is false, the second one is true because 1==1
--
Posted via a free Usenet account fromhttp://www.teranews.co m
OK, thanks, it makes sense now. gr*****@reenie. org wrote:
> This is true: "2-3"==1
But "1-2"==1 is not true
Why ?
I get exactly the opposite results with the antique PHP 4.1.2 on my Linux
system.
What's happening here is that PHP tries to convert the string to an integer
for the comparison, and that conversion stops at the first non-digit (the
"-").
So, converting "2-3" produces the integer 2, and converting "1-2" produces
the integer 1.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stephan Diehl |
last post by:
A while ago, I've posted a recipie about finding a common prefix to a list
of strings. While the recipie itself is quite bad (I have to admit) and I
didn't know at that time that this problem was solved already in the
os.path module.
The interesting part can be found in the commentaries, as this turned out to
be a quest for the most efficient algorithm to solve this particular
problem.
All of this can be found at...
|
by: Mike Thompson |
last post by:
The interning of strings has me puzzled. Its seems to happen sometimes,
but not others. I can't decern the pattern and I can't seem to find
documentation regarding it.
I can find documentation of a builtin called 'intern' but its use seems
frowned upon these days.
For example, using py2.3.3, I find that string interning does seem to
happen sometimes ...
|
by: Rigga |
last post by:
Hi all,
I am wondering why string's are not true objects?.... Let me explain...
If i write the code
Dim x1 as String = "veg"
Dim x2 as String = "veg"
If x1 = x2 then
|
by: Mike |
last post by:
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or
comments on how to make this work I would be grateful! I have been working
on this for the past 4 days and nothing I do seems to get me any closer to
the solution. Below is a program that I am working on for a class project.
The original code was provided for us which is what I have below. What we
have to do is make the app run so that it allows the user to add...
|
by: Venkat |
last post by:
Hi All,
I need to copy strings from a single dimensional array to a double
dimensional array.
Here is my program.
#include <stdio.h>
#include <stdlib.h>
| |
by: sci |
last post by:
I believe both ways to create an array of strings are correct. Is there any
difference between these two?
1. char *MyString = {"First string", "Second string", ..."Tenth
string"};
2. char MyString = {"First string", "Second string", ..."Tenth
string"};
|
by: Michael B. |
last post by:
I was just thinking about this, specifically wondering if there's any
features that the C specification currently lacks, and which may be
included in some future standardization.
Of course, I speak only of features in the spirit of C; something like
object-orientation, though a nice feature, does not belong in C.
Something like being able to #define a #define would be very handy,
though, e.g:
#define DECLARE_FOO(bar) #define...
|
by: Christoph Zwerschke |
last post by:
In Python, it is possible to multiply a string with a number:
>>> "hello"*3
'hellohellohello'
However, you can't multiply a string with another string:
>>> 'hello'*'world'
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
|
by: Dylan Nicholson |
last post by:
I can write a regular expression that will only match strings that are
NOT the word apple:
^(.*|a.*|ap.*|app.*|apple.+)$
But is there a neater way, and how would I do it to match strings that
are NOT the word apple OR banana? Then what would be needed to match
only strings that do not CONTAIN the word "apple" or "banana" or
"cherry"?
|
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: 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: 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();...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |