473,320 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to gvie data type to particular variable

Hello friends,
I am new to perl ,How to give data types to particular variable:
For example:
If x is a scalar variable of type signed integer or unsigned interger how to represent it?


Thanks
Raghavendra
Oct 27 '08 #1
5 2614
nithinpes
410 Expert 256MB
Hello friends,
I am new to perl ,How to give data types to particular variable:
For example:
If x is a scalar variable of type signed integer or unsigned interger how to represent it?


Thanks
Raghavendra
There is no need of declaring datatype in Perl. The datatype will be automatically defined while assigning values. e.g. you can define
Expand|Select|Wrap|Line Numbers
  1. $a=12;
  2. $b="This is a line";
  3. $c='a';
  4. $d= 12.4567;
  5.  
without the need of declaring them as int, string, char or float.
Oct 27 '08 #2
Thanx alot,
my question is how to differentiate signed & unsgined? & how to generate random negative vlues of 32 bit integer.

Thanks
Raghavendra
Oct 27 '08 #3
nithinpes
410 Expert 256MB
Thanx alot,
my question is how to differentiate signed & unsgined? & how to generate random negative vlues of 32 bit integer.

Thanks
Raghavendra
In Perl, there are only three basic datatypes- scalars, arrays and hashes. So, a variable $x can be used to assign a signed or unsigned integer or both in a script. Both signed and unsigned integers will be considered as scalar datatype. Please clarify, if your question is different.

To generate random negative values of 32 bit integer, you may use the following approach:

Expand|Select|Wrap|Line Numbers
  1. $range = 2**31; # 2^(n-1): n=32
  2. $min = -2**31; #lowest integer
  3. $val= int(rand($range)) + $min;
  4. print "$val\n";
  5.  
- Nithin
Oct 27 '08 #4
numberwhun
3,509 Expert Mod 2GB
In Perl, there are only three basic datatypes- scalars, arrays and hashes. So, a variable $x can be used to assign a signed or unsigned integer or both in a script. Both signed and unsigned integers will be considered as scalar datatype. Please clarify, if your question is different.

To generate random negative values of 32 bit integer, you may use the following approach:

Expand|Select|Wrap|Line Numbers
  1. $range = 2**31; # 2^(n-1): n=32
  2. $min = -2**31; #lowest integer
  3. $val= int(rand($range)) + $min;
  4. print "$val\n";
  5.  
- Nithin
I have to agree with nithinpes. You have to remember, Perl isn't C. Some things are just handled.
Oct 27 '08 #5
I have to agree with nithinpes. You have to remember, Perl isn't C. Some things are just handled.
Yes i got it Nithin, Thank you very much.


-Raghavendra
Oct 29 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: gordy | last post by:
edit: this came out longer than I thought, any comments about anything here is greatly appreciated. thank you for reading My system stores millions of records, each with fields like firstname,...
10
by: Zap | last post by:
Widespread opinion is that public data members are evil, because if you have to change the way the data is stored in your class you have to break the code accessing it, etc. After reading this...
11
by: theshowmecanuck | last post by:
As a matter of academic interest only, is there a way to programmatically list the 'c' data types? I am not looking for detail, just if it is possible, and what function could be used to...
5
by: Craig | last post by:
Hi everyone, As a relative new-comer to the wonderful world of .NET Framework and the C# langauge I have come across something that I would like to clarify (hopefully with the help of kind...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
3
by: nineoo | last post by:
To all, Ok , now this may sound a little crazy, but does any one know if there is a way to increase the maximum value of a unsigned long int? I'm aware of the the max value of an...
11
by: Brad Pears | last post by:
I am using a function called "CreateSQLParam" which adds SQL parameters to a collection. The function is shown below... I add a parameter to a collection using the following line code... ...
10
by: John Salerno | last post by:
I wrote some pretty basic socket programming again, but I'm still confused about what's happening with the buffer_size variable. Here are the server and client programs: -------------- from...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.