S
S
SHA_bash2020-09-08 14:56:12
C++ / C#
SHA_bash, 2020-09-08 14:56:12

How to specify the degree when entering?

Hello!
I'm asking the user to enter a value,
but it's a value with exponentiation (for example: 10^-23 ).
Therefore, in what form should this value be entered in
order for it to be successfully written into a variable and used in further calculations?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ronald McDonald, 2020-09-08
@SHA_bash

Therefore, in what form should this value be entered,

There are two options: count the number and degree separately, or write a parser that will parse the string.
The parser is simple: do a split() on the "^" symbol, the first part is a number, the second is the degree. If you do not have split() (not Qt, for example), then look for the occurrence of the "^" character and split it manually, taking the characters before and after the sign, subsequently converting them to a number. Also, do not forget to check if there is a "-" sign in the second part of the line and take appropriate actions on the number by removing the minus itself from the terms.
And if the number is always equal to 10, then you can ask to enter only the degree.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question