Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Working with strings

32 views
Skip to first unread message

Revan NG

unread,
Dec 21, 2011, 1:52:59 AM12/21/11
to
Dear all,

I am currently writing a program that merges 3 to 4 numbers into a
single line.

The program, in a nutshell is this: << A ->STR B ->STR C->STR D->STR +
+ + >>

some numbers have decimal places and I was able to control the
precision using 1 FIX ->STR, or 2 FIX ->STR, which works for me.

however, some numbers do not have decimal places so I used 0 FIX -
>STR, but it always return a "." at the end. i.e. "5." instead of
"5".

I want to know if there is a way for me to remove the "." quickly. I
have looked at the AUG and the user manual, but neither has any info
on string manipulations.

Thanks.

Revan

Uergil

unread,
Dec 21, 2011, 3:02:46 AM12/21/11
to
In article
<4992fef3-821a-44a1...@u10g2000prl.googlegroups.com>,
If you have an HP50 you can use

\<< DUP FP NOT { \->STR "." "" SREPL DROP } IFT \>>

to convert any number to a string and only a decimal point as the last
character will be removed.

I seem to recall that the SREPL command is not available on the 48's.

Note that the "\" in "\<<", "\->" and "\>>" only denote that the
following symbols represent a special HP50 character which the standard
typeface does not allow.
--
"Ignorance is preferable to error, and he is less
remote from the- truth who believes nothing than
he who believes what is wrong.
Thomas Jefferson

Revan NG

unread,
Dec 21, 2011, 4:22:50 AM12/21/11
to
On Dec 21, 4:02 pm, Uergil <Uer...@uer.net> wrote:
> In article
> <4992fef3-821a-44a1-9692-eaa9cdae6...@u10g2000prl.googlegroups.com>,
Thanks!

the command worked beautifully on my 50G. frankly i was expecting a
more direct command to accomplish the same task, something like
removing an element in a list.

Travis Evans

unread,
Dec 21, 2011, 11:41:26 AM12/21/11
to
If you know for sure it's an integer, the trick I usually use is convert
it to a ZINT first using R->I, then use ->STR, to remove the decimal
point.

--
Travis Evans

Travis Evans

unread,
Dec 21, 2011, 11:43:35 AM12/21/11
to
On Tue, 20 Dec 2011 22:52:59 -0800 (PST), Revan NG <rev...@gmail.com> wrote:

Travis Evans

unread,
Dec 21, 2011, 11:46:31 AM12/21/11
to
On Tue, 20 Dec 2011 22:52:59 -0800 (PST), Revan NG <rev...@gmail.com> wrote:

Nemo

unread,
Dec 21, 2011, 6:06:31 PM12/21/11
to
Hi

i'm not sure to understand what you want to do exactly. Is it the
same FIX value for all the datas ? could you give an exemple with
values ?

> I want to know if there is a way for me to remove the "." quickly. I

Try << "." "" SREPL DROP>>

Note that if you are in exact mode ( MODE key then CAS then uncheck
Approx)
3 0 FIX
give 3 and not 3.

You wrote : << A ->STR B ->STR C->STR D->STR + + + >>
Note that you don't have to use so many STR->

For exemple << 1 ->STR 2 + 3 + 4 >> returns "1234" in exact mode or
1.2.3.4. if you are in approx mode.

In the 49/50g 3 is not the same than 3.
3 is an integer value
3. is a real value (3.0)

Gilles

On Dec 21, 7:52 am, Revan NG <reva...@gmail.com> wrote:
> Dear all,
>

John H Meyers

unread,
Dec 23, 2011, 6:42:03 AM12/23/11
to
On 12/21/2011 12:52 AM, Revan NG wrote:

> some numbers have decimal places

> is there a way for me to remove the "."

The HP49/50 calculator series is capable of two fundamentally
different types of numeric computation, one involving
"floating point" results (also known as "approximate" or as "real")
where no more than 12 significant digits are ever retained,
while a separate "exponent" (power of 10) is used to enable
an extremely wide range of large and small magnitudes to be represented,
and the other involving integers of unlimited length and precision,
whose _exact_ value is always retained, no matter how many digits this requires.

To visually distinguish these two fundamentally different object types
from one another, floating point "approximate" values are _always_
displayed with a "radix point" character ("." or "," according to a system flag)
while _exact_ integer values are _never_ displayed with a radix point.

For example, if a value is displayed as 123456789012. (with trailing radix point)
it's entirely possible that this arose as a calculated value of 123456789012.3
but since the calculator always rounds calculated approximate results
to at most 12 significant digits, the closest-valued real number object
that can be delivered as a result is 123456789012. (rounded off),
and is displayed this way to show that it's a limited-precision value,
never assured to have more than 12 digits of precision.

Even a value of 123. or even a value of 1. could likewise
possibly have resulted solely because of the limited precision
of all such "floating point" results -- for example,
the result of calculating 10^(1E-12) appears as 1.
because the next significant digit of the true answer
would be the 13th digit, which has been rounded off.

On the other hand, a value displayed as 123456789012 (no radix point)
or a value displayed as 1 (no radix point)
or a value displayed as -12345678901234567890123 (no radix point)
can only represent an exact result, never a "rounded off" result.

If you want to replace any approximate value whose (approximate)
fractional part appears to be zero by an exact integer value,
that's what command R\->I does,
the new object then displaying without a radix point,
and there will likewise then be no radix point inserted by \->STR,
which is the same function as is internally used to display it on the screen.

[r->] [OFF]

Robert Simitis

unread,
Jan 14, 2012, 4:17:45 PM1/14/12
to
Instead of 0 FIX you may use STD ( with the -105 CF command first )
RS
0 new messages