Skip to main content

Why Variables and Data types are required?

Writing a program means playing with data information. Performing operations on data. And remember no any programming technology performing any operation on data actually. It is a processor's ALU unit which is responsible for operations. ALU fetch data from RAM, perform operations and store back the result on RAM. That's why operators are the same in every programming technology.
RAM made up of cells. and every cell has the size of one byte which is identified by a unique address Nowadays, there is RAMs are in gigabytes i.e. billions of cell on RAM. So much lookup time to find the values on RAM.

To optimize this lookup time Programming technologies reserve some space for themselves initially. When Any Programming technology requests to the processor for some operations on its values. It also specifies their unique names with the request. These names bind with the address of cells internally where values are stored. This will help to find the values immediately. This name is known as Variable Name.

 Variables are name of memory location.
But still, there is one problem to resolve. Data can be a number, alphabet, string, symbols or true/false. Different type of data takes a different memory size. The processor needs to know already that which kind of data is coming to the store. because it has to reserve memory for variables before storing them. So when we request to the processor to store the values we also tell the type of variable as Integer or String etc. These are called DataTypes 

Comments

  1. The Venetian® Casino Resort in Las Vegas, NV - MJH
    Plan your next event or meeting at The 남원 출장샵 Venetian® Casino Resort in Las Vegas, NV. 고양 출장안마 Check 삼척 출장안마 out total event space, meeting 부천 출장샵 rooms, and request a 영주 출장마사지 proposal today.

    ReplyDelete

Post a Comment

suggestions

Popular posts from this blog

Why "F" and "L" suffix | (10.0F, 10L)

Let us take it this way, We will create their needs. So we will get why they are needed. Try to guess, which functions will be executed in the following program: public class MyClass {     public static void main(String args[]) {         MyClass obj = new MyClass();         obj.fun1(10);     }     void fun1(byte val){         System.out.println(val);     }     void fun1(int val){         System.out.println(val);     }     void fun1(float val){         System.out.println(val);     }     void fun1(long val){         System.out.println(val);     }     } It seems like every method is capable to run this program because 10 is still literal because It has no data type. Before Java, In previous technologies, this scenario gave an ambiguity error. But Java solves this problem by removing the concepts of literals. It means Java provide a data type immediately when these born. So here 10 is no more literal. Java provides Integer data type for it. So now it is of Integer t

only large files upload on S3 | Ruby On Rails

models/attachment.rb class Attachment < ApplicationRecord after_initialize :set_storage private def set_storage # larger that 5mb file would be upload on s3 if file . blob . byte_size > 5_000_000 Rails . application . config . active_storage . service = :amazon else Rails . application . config . active_storage . service = :local end end # end of private end

Typecasting | How is Long to Float Conversion possible?

We will take a brief description of Typecasting and will try to do focus on Log to Float Conversion. Typecasting: Assigning a value of one data type to another. When we assign a value of smaller data type to a bigger one. it is called Widening. Java did this conversion automatically as they are compatible. As shown in the following figure: One another kind of conversion, when automatic conversion not possible i.e. when they are not compatible is Shortening. It will be just opposite of above and diagram will be reversed. How is Long to Float Conversion possible? If we look carefully at the diagram, there is one conversion which looks questionable is Long(8 bytes) to Float(4 bytes) conversion. It looks like data lossy conversion. Actually, Type conversion does two things: Either change in range or change in behavior or both. Change in Range: short a = 3456 // this value can be varied within the range of -32768 to 32767 int b = a // now this value can be varied wi