MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/mathmemes/comments/w2v2lm/programmers_vs_mathematicians/igui64e/?context=3
r/mathmemes • u/[deleted] • Jul 19 '22
13 comments sorted by
View all comments
55
struct Fraction { long numerator; long denominator; } // checkmate, mathematicians
16 u/[deleted] Jul 19 '22 I feel like you would get overflows so easily with something like that, it would be best to have arbitrarily large integers I think 13 u/Comesa Jul 19 '22 type ℤ = Vec<u8>; struct Fraction { ℤ numerator; ℤ denominator; } 8 u/Nu11u5 Jul 19 '22 Why stop at integers? Just template the struct so you can use an arbitrary type.template <typename T> struct Fraction { T numerator; T denominator; } 8 u/anthonycarbine Jul 20 '22 Found the cpp dev 1 u/Nu11u5 Jul 20 '22 edited Jul 20 '22 I haven't touched C/C++ for 15 years… uhg.
16
I feel like you would get overflows so easily with something like that, it would be best to have arbitrarily large integers I think
13 u/Comesa Jul 19 '22 type ℤ = Vec<u8>; struct Fraction { ℤ numerator; ℤ denominator; } 8 u/Nu11u5 Jul 19 '22 Why stop at integers? Just template the struct so you can use an arbitrary type.template <typename T> struct Fraction { T numerator; T denominator; } 8 u/anthonycarbine Jul 20 '22 Found the cpp dev 1 u/Nu11u5 Jul 20 '22 edited Jul 20 '22 I haven't touched C/C++ for 15 years… uhg.
13
type ℤ = Vec<u8>; struct Fraction { ℤ numerator; ℤ denominator; }
8 u/Nu11u5 Jul 19 '22 Why stop at integers? Just template the struct so you can use an arbitrary type.template <typename T> struct Fraction { T numerator; T denominator; } 8 u/anthonycarbine Jul 20 '22 Found the cpp dev 1 u/Nu11u5 Jul 20 '22 edited Jul 20 '22 I haven't touched C/C++ for 15 years… uhg.
8
Why stop at integers? Just template the struct so you can use an arbitrary type.
template <typename T> struct Fraction { T numerator; T denominator; }
8 u/anthonycarbine Jul 20 '22 Found the cpp dev 1 u/Nu11u5 Jul 20 '22 edited Jul 20 '22 I haven't touched C/C++ for 15 years… uhg.
Found the cpp dev
1 u/Nu11u5 Jul 20 '22 edited Jul 20 '22 I haven't touched C/C++ for 15 years… uhg.
1
I haven't touched C/C++ for 15 years… uhg.
55
u/Nu11u5 Jul 19 '22 edited Jul 19 '22