How do you transform a number to its sign? [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How do you transform a number to its sign (for example -50 = -1, 50 = 1) without using the if statement, just mathematical operations?

Why not just do this
int sign = i<=0 ? -1 : 1;

Related

How can I acheive this transformation in google sheets? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want the rows on the left to be transformed into the one on the right (by splitting on a comma) ,
Actual data contains thousand of such rows, how can I do it easily?
use:
={A1:D1; ARRAYFORMULA(SPLIT(QUERY(FLATTEN(IF(IFERROR(SPLIT(C2:C, ","))="",,
A2:A&"♀"&B2:B&"♀"&SPLIT(C2:C, ",")&"♀"&D2:D)),
"where Col1 is not null"), "♀"))}

Remove hastag/pound/octothorpe from string in R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a string which has a hastag/pound/octothorpe in it, and want it removed using a regex expression.
e.g.
iii <- '#lkdjljf, lkdflsdkf'
i would like a gsub(regex_bit_here,'',iii)
to remove the hastag/pound/octothorpe
Thanks
I have triedgsub("^#",'',iii), and it works

Regex pattern to not equal 0 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I want to pass values those are not equal zero (0). What is the best performing regex pattern for this ?
[^0]+
Means: Any character besides zero must occur at least once

Regular expression to match n digit before precision and only two digit after precision [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Eg: only allow
< n digit>.<2 digit>
[0-9]{0,}\.[0-9]{2} if you need exactly 2 digit after the dot
[0-9]{0,}(\.[0-9]{1,2}){0,1} if precision can be empty

I need a REGEX to validate a password field [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
The password must have between 6-15 character and cannot allow the & and %.
/^[^&%]{6,15}$/