▲ 151 ▼ pretty small subtotal. (thelemmy.club) submitted 1 year ago by irelephant@programming.dev [M] to c/software_gore@programming.dev 26 comments fedilink hide all child comments
[–] GissaMittJobb@lemmy.ml 8 points 1 year ago (5 children) A currency enum and f64 You failed entirely and should not be handling money in code permalink fedilink source parent hideshow 5 child comments replies: [+] FizzyOrange@programming.dev -8 points 1 year ago (4 children) Why? It sounds like you are under the common and false impression that you can't use f64 for money. permalink fedilink source parent hideshow 4 child comments replies: [–] GissaMittJobb@lemmy.ml 2 points 1 year ago (3 children) You can't use it if you ever want to do any operations on said money, due to the loss of prescision. Enums are not a good idea for the currencies either. permalink fedilink source parent hideshow 3 child comments replies: [–] FizzyOrange@programming.dev 0 points 1 year ago* (2 children) Yes you can. You're vastly underestimating the size of an f64. Give me a concrete example of a money operation that fails with f64 (for normal companies; assuming you aren't a stock exchange or Visa or whatever). Enums are not a good idea for the currencies either. Why not? permalink fedilink source parent hideshow 2 child comments replies: [–] GissaMittJobb@lemmy.ml 3 points 1 year ago (1 child) Yes you can. You're vastly underestimating the size of an f64. Give me a concrete example of a money operation that fails with f64 (for normal companies; assuming you aren't a stock exchange or Visa or whatever). 0.1f64 + 0.2f64 != 0.3f64 Why not? Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea permalink fedilink source parent hideshow 1 child comment replies: [–] FizzyOrange@programming.dev 0 points 1 year ago 0.1f64 + 0.2f64 != 0.3f64 It does if you round it to the nearest penny. Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea Most sensible programming languages allow enums to be non-exhaustive. permalink fedilink source parent
[+] FizzyOrange@programming.dev -8 points 1 year ago (4 children) Why? It sounds like you are under the common and false impression that you can't use f64 for money. permalink fedilink source parent hideshow 4 child comments replies: [–] GissaMittJobb@lemmy.ml 2 points 1 year ago (3 children) You can't use it if you ever want to do any operations on said money, due to the loss of prescision. Enums are not a good idea for the currencies either. permalink fedilink source parent hideshow 3 child comments replies: [–] FizzyOrange@programming.dev 0 points 1 year ago* (2 children) Yes you can. You're vastly underestimating the size of an f64. Give me a concrete example of a money operation that fails with f64 (for normal companies; assuming you aren't a stock exchange or Visa or whatever). Enums are not a good idea for the currencies either. Why not? permalink fedilink source parent hideshow 2 child comments replies: [–] GissaMittJobb@lemmy.ml 3 points 1 year ago (1 child) Yes you can. You're vastly underestimating the size of an f64. Give me a concrete example of a money operation that fails with f64 (for normal companies; assuming you aren't a stock exchange or Visa or whatever). 0.1f64 + 0.2f64 != 0.3f64 Why not? Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea permalink fedilink source parent hideshow 1 child comment replies: [–] FizzyOrange@programming.dev 0 points 1 year ago 0.1f64 + 0.2f64 != 0.3f64 It does if you round it to the nearest penny. Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea Most sensible programming languages allow enums to be non-exhaustive. permalink fedilink source parent
[–] GissaMittJobb@lemmy.ml 2 points 1 year ago (3 children) You can't use it if you ever want to do any operations on said money, due to the loss of prescision. Enums are not a good idea for the currencies either. permalink fedilink source parent hideshow 3 child comments replies: [–] FizzyOrange@programming.dev 0 points 1 year ago* (2 children) Yes you can. You're vastly underestimating the size of an f64. Give me a concrete example of a money operation that fails with f64 (for normal companies; assuming you aren't a stock exchange or Visa or whatever). Enums are not a good idea for the currencies either. Why not? permalink fedilink source parent hideshow 2 child comments replies: [–] GissaMittJobb@lemmy.ml 3 points 1 year ago (1 child) Yes you can. You're vastly underestimating the size of an f64. Give me a concrete example of a money operation that fails with f64 (for normal companies; assuming you aren't a stock exchange or Visa or whatever). 0.1f64 + 0.2f64 != 0.3f64 Why not? Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea permalink fedilink source parent hideshow 1 child comment replies: [–] FizzyOrange@programming.dev 0 points 1 year ago 0.1f64 + 0.2f64 != 0.3f64 It does if you round it to the nearest penny. Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea Most sensible programming languages allow enums to be non-exhaustive. permalink fedilink source parent
[–] FizzyOrange@programming.dev 0 points 1 year ago* (2 children) Yes you can. You're vastly underestimating the size of an f64. Give me a concrete example of a money operation that fails with f64 (for normal companies; assuming you aren't a stock exchange or Visa or whatever). Enums are not a good idea for the currencies either. Why not? permalink fedilink source parent hideshow 2 child comments replies: [–] GissaMittJobb@lemmy.ml 3 points 1 year ago (1 child) Yes you can. You're vastly underestimating the size of an f64. Give me a concrete example of a money operation that fails with f64 (for normal companies; assuming you aren't a stock exchange or Visa or whatever). 0.1f64 + 0.2f64 != 0.3f64 Why not? Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea permalink fedilink source parent hideshow 1 child comment replies: [–] FizzyOrange@programming.dev 0 points 1 year ago 0.1f64 + 0.2f64 != 0.3f64 It does if you round it to the nearest penny. Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea Most sensible programming languages allow enums to be non-exhaustive. permalink fedilink source parent
[–] GissaMittJobb@lemmy.ml 3 points 1 year ago (1 child) Yes you can. You're vastly underestimating the size of an f64. Give me a concrete example of a money operation that fails with f64 (for normal companies; assuming you aren't a stock exchange or Visa or whatever). 0.1f64 + 0.2f64 != 0.3f64 Why not? Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea permalink fedilink source parent hideshow 1 child comment replies: [–] FizzyOrange@programming.dev 0 points 1 year ago 0.1f64 + 0.2f64 != 0.3f64 It does if you round it to the nearest penny. Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea Most sensible programming languages allow enums to be non-exhaustive. permalink fedilink source parent
[–] FizzyOrange@programming.dev 0 points 1 year ago 0.1f64 + 0.2f64 != 0.3f64 It does if you round it to the nearest penny. Encoding in assumptions about a fixed amount of supported currencies in a system is broadly speaking not a good idea Most sensible programming languages allow enums to be non-exhaustive. permalink fedilink source parent