[SOLVED] Bug with INSTRING
|
10-26-2016, 08:37 AM
(This post was last modified: 10-28-2016 07:19 AM by CH3791.)
Post: #1
|
|||
|
|||
[SOLVED] Bug with INSTRING
Hello,
When I put INSTRING("√7","√") directly into CAS, it returns 1 as expected. However when I put the exact same thing into programs, it returns 0. CAS or non-CAS, it doesn't matter. Code: EXPORT norm_instring_bug(expression) It might have something to do with Prime auto-adding spaces, which I found to have caused some issues during my testing. For example, Prime changes "√" to " √ ". If we now calculate INSTRING("√7"," √ "), it returns 0. |
|||
10-26-2016, 01:02 PM
Post: #2
|
|||
|
|||
RE: Bug with INSTRING
An upper-case INSTRING seems to work.
Code:
If an extra space is being inserted, it might be worth trying the equivalent Unicode numeric instead of a string. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
10-26-2016, 06:49 PM
Post: #3
|
|||
|
|||
RE: Bug with INSTRING
(10-26-2016 08:37 AM)CH3791 Wrote: Hello, I don't have a calc or a copy of the VC in my reach, but I wonder if there is any difference between running the programs from CAS vs from HOME. My thought process is that in CAS, entering in √7 leaves the quantity in exact form (assuming the necessary settings are in place) whereas in HOME, the quantity is reduced to a decimal approximation. If this simplification happens before that program is even run (as part of the parsing routine), then this may explain why you get 0 as the result all the time. Han Graph 3D | QPI | SolveSys |
|||
10-27-2016, 06:13 AM
Post: #4
|
|||
|
|||
RE: Bug with INSTRING
Hello,
It might be because your expression is evaluated before the string function is called on it, thus removing the sqrt symbol? Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
10-27-2016, 06:41 AM
(This post was last modified: 10-27-2016 06:45 AM by toml_12953.)
Post: #5
|
|||
|
|||
RE: Bug with INSTRING
(10-26-2016 08:37 AM)CH3791 Wrote: Hello, When I put in the following: Code: EXPORT norm_instring_bug(expression) I get 2 in RPN mode when I enter "√7". I tried with all capitals as well as lowercase keywords. I get 2 every time. Tom L Tom L Cui bono? |
|||
10-27-2016, 09:36 AM
Post: #6
|
|||
|
|||
RE: Bug with INSTRING
To Stephen:
How do I program using unicode numeric? To Han: norm_instring_bug(√7) cas_instring_bug(√7) returns 0 in both Home and CAS. Even if the "exact" setting is ticked in CAS. To Cyrille: At least with the CAS program, it shouldn't have been evaluated right? Because if we have a program like say Code: #cas To Tom: Is your answer of 2 after Prime has automatically added in spaces (so creating a string like this: " √7 ")? Because the answer should be 1 since the √ is in the first position of the string. |
|||
10-27-2016, 01:47 PM
(This post was last modified: 10-27-2016 02:04 PM by StephenG1CMZ.)
Post: #7
|
|||
|
|||
RE: Bug with INSTRING
To represent the square root symbol as a Unicode numeric use this syntax:
Code:
Note: If you look through Shift Chars you can discover other code numbers. But beware that there may be several similar-looking symbols. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
10-27-2016, 03:11 PM
(This post was last modified: 10-27-2016 03:22 PM by StephenG1CMZ.)
Post: #8
|
|||
|
|||
RE: Bug with INSTRING
(10-27-2016 02:03 PM)moonbeam Wrote:(10-27-2016 01:47 PM)StephenG1CMZ Wrote: To represent the square root symbol as a Unicode numeric use this syntax: My apologies. In my original post, I had used shift/chars and picked up a value that looked like a sqrt or tick on my little screen, and wrote the call syntax. I then used asc(sqrrtsymbol) to find out the actual number and updated my post with the right number - but I was too slow and you read the 1st version. BTW, I am surprised that when using Shift/Chars/More/Maths the symbol for squareroot is not immediately seen - I would have thought it would be one of the first/commonest symbols. But I guess that sequence is Unicode's, not HP Prime's. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
10-27-2016, 04:35 PM
Post: #9
|
|||
|
|||
RE: Bug with INSTRING
(10-27-2016 03:11 PM)StephenG1CMZ Wrote: BTW, I am surprised that when using Shift/Chars/More/Maths the symbol for squareroot is not immediately seen - I would have thought it would be one of the first/commonest symbols. But I guess that sequence is Unicode's, not HP Prime's. Welcome to unicode! :-) Yes, the character browser is exclusively showing the codepoints in the font. There are plenty of places where characters appear in more then 1 place, don't appear in the same sequence because they already existed somewhere else, and other strange things. Just take a look at the superscript/subscript block... https://en.wikipedia.org/wiki/Unicode_su...ipts_block TW Although I work for HP, the views and opinions I post here are my own. |
|||
10-28-2016, 07:10 AM
Post: #10
|
|||
|
|||
RE: Bug with INSTRING
Cheers guys,
the program works now! |
|||
11-19-2016, 09:11 PM
Post: #11
|
|||
|
|||
RE: [SOLVED] Bug with INSTRING | |||
11-21-2016, 10:38 AM
Post: #12
|
|||
|
|||
RE: [SOLVED] Bug with INSTRING
Hello Jan
If you want to check for square root symbol, you use this code: Code: instring(yourstring,char(226,136,154)) |
|||
11-21-2016, 03:45 PM
Post: #13
|
|||
|
|||
RE: [SOLVED] Bug with INSTRING
Hello CH3791,
Thank you! |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)