0 Double left, c#

Asked

Viewed 29 times

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?

  • 1

    0 Is number ignoring in double, float and int. Ex: 000001 // 1 ; 010 //10

  • Jeff Henrique. Why do you want to do this?

  • @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.

  • I wanted to make it clear. It’s useless to transfer in double, better string.

  • 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 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.

  • @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.

  • @Augustovasques, in my database, the field is a double, so I can’t send a string to it

  • 1

    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

  • But what I really wanted was to know if I could keep the 0 left in a double field

  • 1

    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

  • Okay, I’ll give the idea at the company, thanks for the personal help

  • 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

Show 8 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.