Jump to content



Photo
- - - - -

How To Right A Line Of Code To Pick Out Certain Digits?


  • Please log in to reply
3 replies to this topic

#1 Alfie Stoppani

Alfie Stoppani

    Newbie

  • Members
  • Pip
  • 13 posts
  • Gender:Male

  • Calculators:
    Fx-9750Gii (with OS 2.00.0200 updated and installed)

Posted 02 March 2012 - 05:35 PM

Hi,

I'm having problems figuring out how to select and set digits within numbers.

For example, I want the user to enter a number:

"Enter Number" ? -> A
(Int log A)+1 -> B

Above would be the start of the program. After this, I would like a line that selects, let's say the 4th digit in the number A and sets its value as C.

How can this be done?

----------

To clarify what I mean:
"Enter Number" ? -> A
<-- User enters number, e.g 442
(Int log A)+1 -> B
<-- This responds as how many integer digits the number has, in our case for 442, 3.
After this I want the second digit in 442 to be selected and set as C.

Hope you can help. Thank You.

Alf. <:3D~

#2 flyingfisch

flyingfisch

    Casio Maniac

  • Deputy
  • PipPipPipPipPipPipPipPip
  • 1891 posts
  • Gender:Male
  • Location:OH,USA
  • Interests:Aviation, Skiing, Programming, Mountain Biking.

  • Calculators:
    fx-9860GII
    fx-CG10 PRIZM

Posted 02 March 2012 - 06:00 PM

If you are new to this board, you should introduce yourself here ;)

#3 Forty-Two

Forty-Two

    Casio Overlord

  • Deputy
  • PipPipPipPipPipPipPip
  • 528 posts
  • Gender:Male
  • Location:Well, The sign says "You are here"...

  • Calculators:
    Casio fx-CG10 Prizm
    Casio fx-9860GII
    TI-84+ SE

Posted 02 March 2012 - 11:08 PM

You'll want to split the number just above and below the digit you want to replace, then multiply C by the place valuse of the digit, and add the remaining vars togather. The biggest problem would be the splitting. For the upper numbers, you could devide them so that only the numbers that are to the left of the digit you want to replace are to the left of the decimal; you could then get the number part of that. A similar strategy could be aplied to the numbers belw the decimal. Be aware that this will all fail if you try to replace a digit with a to-digit number.

#4 somebody1234

somebody1234

    Casio Addict

  • Members
  • PipPipPip
  • 51 posts

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

Posted 08 February 2014 - 02:00 AM

Does this work?:
StrMid(Str 1, 2, 1) -> Str 2
String 1, 2nd Char, 1 char long (I think)
(Sorry, I'm not very good at string stuff)

Edited by flyingfisch, 09 February 2014 - 03:37 AM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users