Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,425 members, 7,954,669 topics. Date: Saturday, 21 September 2024 at 06:20 AM |
Nairaland Forum / Science/Technology / Programming / Integer Types Should Inherit From ... (983 Views)
What Exactly Do Modifier Types In C++ Do? More Emphasis On Integer Modifiers / Reverse Python Integer Using Reverse_int (2) (3) (4)
(1) (Reply)
Integer Types Should Inherit From ... by asalimpo(m): 10:06pm On Dec 01, 2017 |
Actually integer types should be descendants of Doubles. Y? Because all integers can be expressed as double types, just tack a '.0' to it and it becomes a double. Also mathematically, integers are subsets of doubles (i.e rationals). But in most oop languages, integers are separate entities directly descending from abstract class Number/or Real same as Doubles. This shouldnt be,it's a design flaw. if i were to architect the heirarchy, Long Types (actually integers) would descend from doubles, which will descend from Real (Real numbers) which will descend from Number. |
Re: Integer Types Should Inherit From ... by Olyboy16(m): 1:19pm On Dec 02, 2017 |
asalimpo:so if integers "inherit" from double(which is a scientific taboo), how many bits would then store an int? and how would you suppose memory registers would handle this? also with respect to performance analysis, how would you suppose compilers differentiate an integer pointer from a double one? |
Re: Integer Types Should Inherit From ... by asalimpo(m): 9:09pm On Dec 02, 2017 |
Olyboy16:I dont know which grammer u are speaking there. In ur favorite oop language, doubles can hold integers. Which means, doubles are the parent class of integers and will always be conceptually. The designers of the language should have just expressed this relationship architecturally instead of spin of integers as separate entities. Scientifically what? Mathematically, the set Rationals, contains the set Integers. which puts paid to the argument that integers descend from Rationals,the same set Doubles (which are mathematically rationals descend from). Creating a more streamlined architecture will not affect the underlying implementation at all. Cuz underneath,it's all bits - 1s and 0s. If strings can be resolved at that level any other hierarchy can.
I'm assuming rational is used instead of the name ,double or floating point. Consider that in java, a BigDecimal can be initialized with a BigInteger. e.g BigInteger b = new BigInteger(1000000000); BigDecimal n = new BigDecimal(b); So BigDecimals are the supertypes of bigIntegers,which underscores what i'm trying to say. That integers descend from doubles / rationals. |
(1) (Reply)
Please Who And How Was Nct Community And Every Knows Built / Where can i learn programming in a professional way / Audio And/or Video Calling App Design Needed
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14 |