[Programming Language Week2] Data type, Specification, Type Checking, Floating point vs Fixed point

Hailey·2020년 9월 14일
1

Computer Science

목록 보기
3/9

Introduction

Three major components in a programming language

  • Data
    : Basic information unit to hold values to determine the state of a system
  • Operations
    : Actions to manipulate data or sequencing
  • Control
    : A mechanism provided to control the sequence of instructions

Basic Concepts for Data

  • Data storage of an actual computer
    -- Memory, register or external media
    -- Usually have simple structure as sequence of bits comprising bytes or words

  • Data storage of a virtual computer
    -- Arrays, stacks, numbers, character strings

In C) arrays
int arr[10]={1,2,3,4,5,6,7,8,9,10};
char arr2[12]="hello world";

-- Usually have more complex organization

In C) structure
struct info{
	int number;
    	int age;
    	char name[4]; } person; 
  • Data Object
    -- Run-time grouping of one or more pieces of data in a virtual computer
    -- Some are defined by programmer (variables, constants, arrays) and others are defined by system for house keeping(activation records)

    -- Container for a data value (a single number, character or a memory location)
    -- Classified as elementary object (manipulated as a single unit) or structured object (aggregated)
    -- Each data object has a lifetime (extent)

  • Attributes associated with a data object
    -- Name: Represent the object and is referred during execution time (N, M)
    -- Type: Specify the data values that the object may contain (int, char)
    -- Location: Address of the storage where the object is located (0x3a789b85)
    -- Value: Actual value that the object containes (30, 20)
    -- Component: The binding of a data object to one or more data objects (S[10])
    -- Operations: Mechanisms to manipulate the object (+, -)

  • Variable
    -- A data object that is defined and named by programmer explicitly in a program
    -- The content(value) of a variable can be changed during its life time
    -- Simple variable : an elementary data object with a name
    -- Complex variable : group of variables

  • Constant
    -- A data object with a name which is bound to a value permanently during its lifetime
    -- Types of constants
    -- Literal : representation is the written representation of the value
    -- Programmer defined constant : name is chosen by the programmer


  • Data type
    : A class of data objects together with a set of operations for creation and manipulation
    : Examples of types are array, integer, file, float, etc.
    -- Classes of data type
    -- Primitive data type: built into the language
    -- User-defined data type: with facilities that the language provides
    -- Self-modifying types: content of data object is modified without programmer's control
    -- Specification and Implementation of data types
    -- Specification : a way of specifying defined data type as an object with attributes, values and operations
    -- Implementation : a way of simulating defined data type on the virtual computer wirh representation and algorithm

  • Specification
    -- Attributes: that distinguish data objects of that type
    ex) Number of dimensions, subject range, data type of components
    -- Values: that data objects of that type may have
    ex) Set of numbers
    -- Operations: that define the possible manipulations of data objects of that type
    ex) consider array data type
    Subscribing to select a component, create array, change shape, access attributes, and perform arithmetic on a pair of array

  • Implementation
    -- Storage representation: used to represent the data object of that type (integer is stored in a word)
    -- Algorithm: manner in which the operations are defined to manipulate the data object(procedures)

Elementary Data Type

  • What is the Elementary Data Type?
    : It contains a single data value, with various operations
    : Integer, Real, Character, Boolean, Enumeration, Pointer
  • Specification of Elementary Data Types
  1. Attributes
    -- Basic attributes(name, data type) are invariant during its life time
    -- Attribute information could be stored in dope vector(descriptor) or only used to determine storage size
  2. Values
    -- Type of an object determines the set of possible data values
    -- Usually closely related to the values that the underlying hardware provides
    -- The set of values for a data type is usually an ordered set
  3. Operations
    -- Determine how data objects of that type may be manipulated
    -- Primitive operation: part of language definition
    -- Programmer defined operation: form of subprograms, or method declaration
    -- Elements of an operation
    Domain : a set of possible input values
    Range : a set of result values
    Action : determines results from any given set of input values
    -- Signature is used to specify and operation's elements

  • Four main factors that combine to obsucre the definitions of operations
  1. Operations undefined for centain inputs or outputs
  2. Implicit arguments: use of global variable
  3. Side effects (implicit results): change global variable
  4. Self-modification: history sensitive actions like counter, random number generator, LISP allows self modification through code change ( + 4 5 )
  • Subtype (subtype polymorphism)
    -- a form in which a datatype is related to another datatype (the super type)
    -- program elements, typically subroutines or functions, written to operate on elements of the supertype can also operate on elements of the subtype
    -- Time & Space complexity are reduced


  • Implementation of elementary data types
    -- Storage representation for data objects and values of that type
    -- Strongly influenced on underlying hardware (efficient)
    -- Sometimes it is software simulated(inefficient)
    -- Data attributes are determined by compiler in many languages or sometimes data attributes are stored in a descriptor vector (e.g. LISP)
    -- Set of algorithms or procedures that defines the operations of the type
    -- Directly implemented by hardware
    -- As a procedure or function subprogram
    -- As in-line code sequence

  • Declarations
    -- Definition
    : Statements that specify information about the name, type of data object, and lifetime of each object
    -- Explicit declaration vs. Implicit (default) declaration

    -- Declaration of operations can be done by the signature of each operation

  • Purpose of declaration

  1. Choice of stroage representation for translator
  2. Storage management by specifying the lifetime of variables
  3. Polymorphic operations
  4. Type checking
  • Polymorphic operations
    -- Polymorphic function : a subprogram of function that can assume more than one type
    -- Ex) f(x) = x in PASCAL
    function f(x:int): int;
    function f(x:boolean): boolean;
    function f(x:real): real;
  1. Ad hoc polymorphism
    : Different code for different manifestations of the operators
    : Overloading
    : Implicit coercion
  2. Universal polymorphsim (Generic Polymorphism)
    : A function name selects on a variety of implementations depending on the types of its arguments

  • Type Checking
    : Checking the proper number of arguments of the proper data type of each operations
  1. Static type checking
    -- Operation checking: number and types of arguments and results
    -- Variable checking: type of object under the name
    -- Type of constant: syntactic form of literals
    -- Efficient but not flexible
  2. Dynamic type checking
    -- Difficult to debug
    -- Slow execution speed for type checking
    -- Limit the compiler optimization due to unknown factors
    -- Flexibility is enhanced but inefficient
  3. Strong typing
    -- Detect all type errors statically
  • Volatile Type
    -- Variable type whose value could be changed by outside operation
    -- Optimization is not applied to the volatile variables
    -- Use of volatile types
    (1) MMIO (Memory-mapped I/O)
    (2) Interrupt Service Routine
    (3) Multi-Thread Environment
  • Type safe system
    : A function cannot generate result with a type outside of the signature

  • Type inference
    -- Types can be resolved from the program by how they are used
    -- Ex) fun area (length : int, width: int)
    int= length*width

  • Type conversion
    -- Takes one type and produce the corresponding type
    -- Explicit type conversion by using a set of built-in functions
    -- Implicit type conversion (type coercion = 묵시적형변환) as specified in the language
    -- Basic principle is "not to lose information" called widening, or promotion


Integers

  1. Specification
  • Attribute : type attribute integer only
  • Value : ordered and finite subset of integer values
  • Operations :
    -- Arithmetic operations - BinaryOp( +, -, x, /, mod ), UnaryOp(-, +, abs)
    -- Relational operations - ( equal, not equal, less-than... )
    -- Assignment operations - ( :=, = )
    -- Bit operations - ( &, | , <<, >> )
  1. Implementation
  • Use complete memory word
  • Three possible storage representation
    -- No runtime descriptor
    -- Descriptor stored in seperate words (LISP)
    -- Descriptor stored in the same word

Floating point real numbers

  1. Specification
  • Attribute: type attribute real
  • Value: hardware determined numbers from min to max, and not evenly distributed
  • Operations: same operations with integers except boolean that has some restrictions(=)
  1. Implementation

    -- Split the storage location into mantissa and exponent (IEEE-754)

ex) Convert 118.625 (Decimal number) in IEEE 754 format
(1) Sign bit = 1
(2) Convert it to binary number : 1110110.101
(3) Left shift to make 1110110.101 = 1. 110110101 x 2^6 : Floating poing number
(4) Padding with 0's to make 23 bits : 110 1101 0100 0000 0000 0000
(5) Exponent is 6, thus add bias (127) and add 6 + 127 = 133 (1000 0101)

Fixed-point real numbers

  1. Specification
    -- Digit sequence of fixed length
    -- Avoid round-off errors (e.g. dollar and cents)
    -- Scale factor

  2. Implementation
    -- Either supported by hardware or simulated by software

    -- Calcultation is done after converting the numbers in the same format

Enumeration

  1. Specification
  • Allow a programmer to define and manipulate subranged variables more directly
  1. Implementation
  • Allocated within the minimum number of bits needed
  • Each entry is numbered with 1,2,3, ... and simple operations on the index numbers are used
  • Use primitive operations of the superset
profile
Cloud Solution Architect - Customer Success in security💗🌎

29개의 댓글

comment-user-thumbnail
2023년 10월 20일

Solid breakdown of data type specification and type checking in programming languages! It's crucial to understand these concepts for robust code. On a related note, I found an interesting article on healthcare data storage that delves into the challenges and solutions in safeguarding sensitive health information: https://www.cleveroad.com/blog/healthcare-data-storage/. It might add another layer to your exploration of data-related topics!

답글 달기
comment-user-thumbnail
2023년 12월 22일

Fascinating read on data types and type checking! The nuances between floating-point and fixed-point were particularly enlightening. For those looking to apply these concepts in web development, check out this helpful guide on the best programming languages for web development https://attractgroup.com/blog/best-programming-languages-for-web-development-and-where-to-get-custom-web-development-services/ , which also covers where to find bespoke services. A great resource to complement your learning!

답글 달기
comment-user-thumbnail
2024년 5월 15일

E-commerce development services https://www.daffodilsw.com/ecommerce-development-services/ refer to the professional services involved in creating, maintaining, and improving online stores or e-commerce websites. These services encompass a wide range of activities that ensure an e-commerce platform is functional, user-friendly, secure, and scalable to handle the needs of online businesses.

답글 달기
comment-user-thumbnail
2024년 5월 15일

offshore development company https://www.daffodilsw.com/offshore-development-company/ is a business that provides software development services from a location outside the client's home country. These companies are often located in countries where the cost of labor is lower compared to the client's local market, which can lead to significant cost savings for clients.

답글 달기
comment-user-thumbnail
2024년 5월 15일

Healthcare software development services encompass the design, development, implementation, and maintenance of custom software solutions https://www.daffodilsw.com/healthcare-software-development-services/ specifically for the healthcare industry. These services aim to improve the efficiency, quality, and delivery of healthcare through technology. Healthcare software solutions are used by a wide range of professionals, including doctors, nurses, hospital administrators, and patients, providing various functionalities to meet the diverse needs of the healthcare sector.

답글 달기
comment-user-thumbnail
2024년 5월 15일

EMR (Electronic Medical Records) and EHR (Electronic Health Records) https://www.daffodilsw.com/healthcare-software-development-company/emr-ehr-integration-services/ integration services involve the process of linking different healthcare software systems and databases to allow for seamless sharing and updating of patient medical records across various healthcare platforms. The goal of integration is to create a cohesive, interoperable system that enables healthcare providers to access and manage patient information more efficiently and effectively.

답글 달기
comment-user-thumbnail
2024년 5월 15일

AI development services refer to the range of services offered by companies or individuals specializing in the creation of artificial intelligence solutions. These services encompass the design, implementation, and integration of AI algorithms https://www.daffodilsw.com/ai-development-services/ and models into various applications and systems to automate processes, enhance decision-making, and provide insights that would not be possible with traditional software solutions.

답글 달기
comment-user-thumbnail
2024년 5월 15일

SaaS (Software as a Service) consulting services are professional services offered by consultants or consulting firms that specialize in helping https://www.daffodilsw.com/saas-consulting-services/ businesses navigate the complexities of adopting and leveraging SaaS solutions. These services can cover a wide range of needs, from selecting the right SaaS products to optimizing their use for a business's unique requirements.

답글 달기
comment-user-thumbnail
2024년 5월 15일

UI/UX consulting refers to the professional services https://www.daffodilsw.com/ui-ux-design-services/uiux-consulting/ provided by consultants or consulting firms that specialize in user interface (UI) and user experience (UX) design. These consultants help businesses enhance the usability, accessibility, and overall experience of their digital products, such as websites, mobile apps, and software applications.

답글 달기
comment-user-thumbnail
2024년 5월 15일

AWS (Amazon Web Services) consulting services https://www.daffodilsw.com/cloud/aws-consulting-services/ are professional services offered by consultants or consulting firms that specialize in helping businesses leverage AWS, which is one of the leading cloud service platforms. AWS provides a wide array of cloud computing services and resources such as computing power, storage options, networking, databases, machine learning, analytics, and much more.

답글 달기
comment-user-thumbnail
2024년 5월 15일

Data enrichment services involve enhancing, refining, and improving raw data to make it more valuable and useful for business intelligence, analytics, https://www.daffodilsw.com/data-enrichment-services/ and operational purposes. These services are provided by companies that specialize in processing and augmenting data with additional relevant information or by transforming it into a more usable format.

답글 달기
comment-user-thumbnail
2024년 5월 15일

Software development services encompass a broad range of activities related to the process of creating, designing, deploying, and maintaining software. These services are offered by software development https://www.daffodilsw.com/software-development-services/ firms, IT consultancies, or individual contractors/freelancers and can cater to various types of software, including desktop applications, mobile apps, web applications, enterprise software, and more.

답글 달기
comment-user-thumbnail
2024년 5월 15일

DevOps services encompass a range of offerings provided by IT service providers, consulting firms, or in-house teams to implement and support DevOps practices https://www.daffodilsw.com/devops-services/ within an organization. DevOps is a set of practices that combines software development (Dev) and IT operations (Ops) with the goal of shortening the system development life cycle, providing continuous delivery, and achieving high software quality.

답글 달기
comment-user-thumbnail
2024년 5월 15일

Telemedicine software development refers to the process of designing, building, and maintaining software applications that enable healthcare https://www.daffodilsw.com/healthcare/telemedicine-software-development/ providers to diagnose, treat, and manage patients remotely using telecommunications technology. This type of software typically facilitates virtual consultations between patients and healthcare professionals through video conferencing, secure messaging, and other digital communication tools.

답글 달기
comment-user-thumbnail
2024년 5월 15일

Software engineering services https://www.daffodilsw.com/software-engineering-services/ encompass the systematic and disciplined approach to developing, operating, and maintaining software. These services are offered by software engineering firms, IT consultancies, or individual software engineers and cover every stage of the software development life cycle (SDLC). The goal is to produce high-quality software that meets or exceeds customer expectations and is delivered on time and within budget.

답글 달기
comment-user-thumbnail
2024년 5월 15일

EHR software, short for Electronic Health Records softwarehttps://www.daffodilsw.com/healthcare/ehr-software/ , is a digital platform that healthcare providers use to create, manage, and track patient health records electronically. This type of software has largely replaced traditional paper-based records, offering a more efficient, accessible, and secure method of managing patient information.

답글 달기
comment-user-thumbnail
2024년 5월 15일

Business intelligence (BI) consulting refers to the professional https://www.daffodilsw.com/business-intelligence-consulting/ services provided by consultants or consulting firms that specialize in helping organizations make better data-driven decisions. These services involve the use of BI tools and practices to transform raw data into meaningful insights that can inform strategic and operational decision-making.

답글 달기
comment-user-thumbnail
2024년 5월 15일

Software maintenance and support services https://www.daffodilsw.com/software-maintenance-and-support-services/ are a crucial part of the software development life cycle, focusing on the upkeep and continued operation of software applications after they have been deployed. These services ensure that software continues to run smoothly, remains secure, and is updated to meet evolving user needs and technological advancements.

답글 달기
comment-user-thumbnail
2024년 5월 15일

E-learning software development is the process of designing, creating, and maintaining software applications used for educational purposes. This can include a https://www.daffodilsw.com/custom-elearning-software-development/ wide range of digital learning solutions such as online courses, virtual classrooms, learning management systems (LMS), mobile learning apps, educational games, and more.

답글 달기
comment-user-thumbnail
2024년 5월 15일

UI/UX design services https://www.daffodilsw.com/ui-ux-design-services/ are professional services that focus on creating user interfaces (UI) and crafting user experiences (UX) for digital products like websites, mobile apps, and software applications. These services aim to make digital products not only aesthetically pleasing but also functional, easy to use, and effective in meeting the needs of users.

답글 달기
comment-user-thumbnail
2024년 5월 15일

Digital commerce services https://www.daffodilsw.com/digital-commerce-services/ refer to a suite of services that enable businesses to conduct buying and selling transactions online. These services encompass the development, implementation, and management of digital platforms and tools for e-commerce, as well as strategies to optimize online sales and customer experiences.

답글 달기
comment-user-thumbnail
2024년 5월 15일

Application security consulting is a https://www.daffodilsw.com/application-security-consulting/ specialized service provided by security experts or consulting firms to help organizations protect their software applications from security threats and vulnerabilities.

답글 달기
comment-user-thumbnail
2024년 5월 15일

healthcare app development company https://www.daffodilsw.com/healthcare-app-development-company/ specializes in creating software applications designed for the healthcare industry. These companies combine expertise in mobile app development with an understanding of healthcare requirements, regulations, and best practices to deliver solutions that can be used by patients, doctors, hospitals, clinics, and other healthcare providers.

답글 달기
comment-user-thumbnail
2024년 7월 18일

E-commerce development services, offered by AddWeb Solution at https://www.addwebsolution.com/ecommerce-development, involve professional expertise in building, maintaining, and enhancing online stores or e-commerce websites. These services cover various tasks aimed at ensuring that an e-commerce platform is operational, user-friendly, secure, and scalable to meet the demands of online businesses.

답글 달기
comment-user-thumbnail
2024년 7월 18일
답글 달기
comment-user-thumbnail
2024년 7월 18일

Discover the comprehensive breakdown of Tesla Supercharger costs and the benefits of Tesla's fast-charging network. Learn how partnering with an EV charging app development company can enhance the electric vehicle experience.

Read more: https://www.addwebsolution.com/blog/how-much-does-tesla-supercharger-cost

답글 달기
comment-user-thumbnail
2024년 7월 18일

Stay ahead of the curve with insights on the upcoming Google Core Update 2024. Learn how to optimize your website to align with Google's latest algorithm changes. Get expert tips and strategies to maintain or improve your search engine rankings.

Read more: https://ashishjain-95034.medium.com/the-latest-new-google-core-update-is-coming-in-weeks-c895e5cf0069

답글 달기
comment-user-thumbnail
2024년 7월 18일

Boost Customer Engagement with WhatsApp Business API in 2024

Discover how the WhatsApp Business API transforms customer communication and boosts engagement. Learn the benefits of integrating the WhatsApp Business App for seamless, efficient interactions. Explore the top WhatsApp Business API benefits with AddWeb Solution.

Learn more: https://www.addwebsolution.com/blog/whatsapp-business-api

답글 달기
comment-user-thumbnail
2024년 7월 29일

The scope of AI software has significantly expanded. AI-driven solutions are now being adopted across various sectors, including healthcare, finance, agriculture, and logistics, to improve efficiency, accuracy, and scalability. https://www.coherentsolutions.com/artificial-intelligence . In healthcare, AI applications extend beyond diagnostic imaging and patient data analysis; they also play a crucial role in predicting disease outbreaks and personalizing treatment plans with high precision. Financial institutions use AI to forecast market trends, manage risks, and detect fraudulent activities in real-time.
As AI continues to redefine the contours of modern existence, its development in 2024 stands as a testament to human ingenuity and the relentless pursuit of progress. The fusion of cutting-edge technology with ethical stewardship will be pivotal in shaping an AI-driven future that is equitable, sustainable, and profoundly transformative.
Looking ahead, the future of AI software development promises even greater integration with human activities, driven by advancements in human-computer interaction, robotics, and cognitive computing. The collaboration between AI and human intelligence is expected to create synergistic solutions that transcend individual capabilities, heralding a new era of technological and societal transformation.
This comprehensive overview of the Artificial Intelligence Robots market is both insightful and forward-thinking. The detailed breakdown of various AI-powered robotic systems, from industrial robots to autonomous vehicles, highlights the incredible scope and versatility of this technology. It's fascinating to see how advancements in AI algorithms and sensor technologies are driving market growth and enabling robots to operate in complex environments. The analysis of regional dynamics and future trends, such as human-robot interaction and edge computing, provides a clear vision of the transformative impact AI robots will have across industries and societies. Excellent read!

답글 달기