Jump to content



Photo
- - - - -

Changing Variable To String


  • Please log in to reply
11 replies to this topic

#1 zubrun

zubrun

    Newbie

  • Members
  • Pip
  • 7 posts

  • Calculators:
    9860 gii

Posted 05 February 2015 - 08:22 PM

Help please....how to change a variable say A resulting from a calculation to a string. Can't manage it.

#2 Sheepolution

Sheepolution

    Newbie

  • Members
  • Pip
  • 21 posts
  • Gender:Male
  • Location:The Netherlands

  • Calculators:
    CFX-9850GC PLUS

Posted 05 February 2015 - 08:51 PM

You can't. ¯\_(ツ)_/¯

 

But, don't worry. What exactly is it that you want to achieve here? There might be ways around it.

 

For example, this is my 'Put' program, that I use to put characters on position A, B

 

http://pastebin.com/u5hF5vps


Edited by Sheepolution, 05 February 2015 - 09:07 PM.


#3 zubrun

zubrun

    Newbie

  • Members
  • Pip
  • 7 posts

  • Calculators:
    9860 gii

Posted 06 February 2015 - 04:02 AM

Tnx Sheepolution....i want to write short programme for palindrome ...so i need to input say a number invert it then add together & repeat procedure until i get palindrome/ symetrical number. First input from ? Ok or if inputted by " " otherwise not possible for second and subsequent step say from a variable because i have to create a variable to avoid inputting by hand each time.

#4 Sheepolution

Sheepolution

    Newbie

  • Members
  • Pip
  • 21 posts
  • Gender:Male
  • Location:The Netherlands

  • Calculators:
    CFX-9850GC PLUS

Posted 06 February 2015 - 08:35 AM

So just to be clear here, what exactly is it you want to achieve? It does seem like something that would be quite a brain teaser, but that's what makes casio basic so much fun.

 

  • You ask the user for a number
  • You give any number, for example: 123
  • You add the number in reverse, so that it becomes a palindrome, for example: 123321

 

And then have that number stored in a variable for further use. That's it right?

 

Turning the number into a palindrome is going to be tough, but it shouldn't be impossible.



#5 somebody1234

somebody1234

    Casio Addict

  • Members
  • PipPipPip
  • 51 posts

  • Calculators:
    Casio fxcg10
    Casio fx-9860GII
    Casio Classpad 400

Posted 06 February 2015 - 08:39 AM

Variable to String

For log L-> K To 1 Step -1
Intg (D/(10^(K-1)))->Z
10(Frac(Z/10))->Y
Str 1 + StrMid(Str 3, Y+1,1)->Str 1
Next

String back to variable

For (StrLen(Str 1))->A To 1 Step -1
If StrCmp(StrMid(Str 1,A,1),StrMid(Str 3,J+1,1))=0
Then B+(J*10^((StrLen(Str 1)-M-1))->B
C+(J*10^M)->C
M+1->M
IfEnd
Next

The code is somewhere in here: https://www.dropbox....LINDRM.G1M?dl=0



#6 zubrun

zubrun

    Newbie

  • Members
  • Pip
  • 7 posts

  • Calculators:
    9860 gii

Posted 06 February 2015 - 04:00 PM

Sheepolution &.somebody1234 first many tnx now
..pls note.
Number say 89 invert 98 add 187 then again reverse 781 add becomes 968 and continue until it becomes palindrome/symetrical.
So it is vital to have ability to change a variable to string. This makes program simple & short.
In d meantime i try to understand suggestion by somebody1234...here old man!!!

#7 Sheepolution

Sheepolution

    Newbie

  • Members
  • Pip
  • 21 posts
  • Gender:Male
  • Location:The Netherlands

  • Calculators:
    CFX-9850GC PLUS

Posted 06 February 2015 - 07:10 PM

What kind of calculator do you have? I think the features somebody1234 uses aren't in my calculator.

 

Now I understand way better what you want to do.

 

and continue until it becomes palindrome/symetrical.

 

 

But isn't there a chance it will never become a palindrome?

 

Meanwhile, I'm going to try to come up with a solution.



#8 zubrun

zubrun

    Newbie

  • Members
  • Pip
  • 7 posts

  • Calculators:
    9860 gii

Posted 06 February 2015 - 07:40 PM

Hi Sheepolution...my calculator is 9860 gii updated to version 2.04....maybe Casio should seriously think to include this possibility of changing a variable to string in their next update..vers 2.05.
This would simplify programs. The only possibility presently is changing expressions used for graphs into strings...not much help in my case.

#9 zubrun

zubrun

    Newbie

  • Members
  • Pip
  • 7 posts

  • Calculators:
    9860 gii

Posted 07 February 2015 - 11:38 AM

Sheepolution....of course there some numbers which never become palindromes....and some big mathematicians devoted a lot of study about these exceptions. But i am old man and wish to have some fun with my Casio...that is why i wish Casio engineers include this possibility because this would make the program not more than 10 lines.

#10 Sheepolution

Sheepolution

    Newbie

  • Members
  • Pip
  • 21 posts
  • Gender:Male
  • Location:The Netherlands

  • Calculators:
    CFX-9850GC PLUS

Posted 07 February 2015 - 01:31 PM

So, there are ways around this, but it's going to be pretty long, it will take a lot more than 10 lines, and it's going to be quite slow. But here is what you can do:

 

First, you need to decide how many digits you have. You can do this by dividing the number by 10, adding value to your counter, until number < 1.

 

Then, you want to store each digit. Let's say our number is 736:

You divide the number by 10

 

73.6

 

And then take that number and abstract the floored number from it.

 

73.6 - 73 = 0.6

 

Then you multiply it by 10, and you have 6.

 

Now for the number 3.

 

You divide 736 by 10, and floor it.

 

Int 73,6 = 73

 

Then you divide it by 10 again, and substract the floored number from that.

 

7,3 - 7 = 0.3

 

Then you multiply it by 10, and you have 3.

 

And then we need to do 7 as well, and this is only a 3 digits number. And after that we need to place the numbers in reverse.

 

Do you get how long this is going to take? So yeah, it is possible, but I'm not sure if this is really what you want, if it's going to take so much lines and time.



#11 zubrun

zubrun

    Newbie

  • Members
  • Pip
  • 7 posts

  • Calculators:
    9860 gii

Posted 08 February 2015 - 12:05 AM

Sheepolution...tnk u for ur mental effort....i appreciate but i have a simpler method. AND wat ru going to do for second time inversion??? Not possible i think unless u get d whole number a string...how ru going to tell program make last digit first unless u have a string???
Tnk u but i think it is for Casio engineers to provide a simple solution or is it also difficult for them !!!
As for somebody1234 i dont have dropbox so until i subscribe i cannot analyze.
I only hope Casio will consider this in their next update.

#12 zubrun

zubrun

    Newbie

  • Members
  • Pip
  • 7 posts

  • Calculators:
    9860 gii

Posted 08 February 2015 - 02:41 AM

Sheepolution....yes ur right it can be done ...i have thought abt it (ESP??)....but its a long long road. And its no fun being not something important or necessary its not worth all that effort. It wud be great if Casio introduces this possibility. Thanks agn!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users