1
Hello, I’m doing the following:
Fun_CPF = Convert.ToDouble(FuncionarioViewModel.Fun_CPF2),
CPF2
It is a string that can contain any Cpf, including Cpf starting with 0, such as 05669774144
, but when I do this conversion, Fun_CPF
receives 5669774144
, what can I do?
0 Is number ignoring in double, float and int. Ex: 000001 // 1 ; 010 //10
– Maury Developer
Jeff Henrique. Why do you want to do this?
– Augusto Vasques
@Maurydeveloper, do not radically change the content of the comments, especially if someone has already marked relevance, this can generate discussion. If you need to delete and write another one or keep the old comment and write a new one.
– Augusto Vasques
I wanted to make it clear. It’s useless to transfer in double, better string.
– Maury Developer
I am transforming, because I will send to the database, and there is string, but I did not try to send in string format, I will try @Maurydeveloper
– Jeff Henrique
Jeff Henrrique: CPF, RG, Phone, home number you send to the database as string(char or varchar) only cardinal quantities(can be counted or fractionated) and ordinals(can be enumerated) you send as numeric.
– Augusto Vasques
@Maurydeveloper, I didn’t mean to draw your attention. It’s just that I read on the meta a post of yours where you said you were cursed(a) and sometimes a change of content in a comment or response can generate an impulsive reaction that results in disagreement.
– Augusto Vasques
@Augustovasques, in my database, the field is a double, so I can’t send a string to it
– Jeff Henrique
The only solution I can think of is to change the field in the database, but I don’t know if it can, it’s from my company, I’m going to discover dps
– Jeff Henrique
But what I really wanted was to know if I could keep the 0 left in a double field
– Jeff Henrique
It is simple, if you want to show the 0 to the left just do not convert. For numbers there is no zero sense left, which adds nothing to the number, to have zeros left hold string
– Ricardo Pontual
Okay, I’ll give the idea at the company, thanks for the personal help
– Jeff Henrique
No, Maury Developer and Ricardo Pontual have already written that the zeroes on the left are ignored. There is a consensus that there are 11 digits in the CPF so you would have to count how many digits make up your number and subtract from 11 so you add as many zeros left as you give this account
– Augusto Vasques