0

Dear All,

Can anybody tell me how to autoincrement the Hexa decimal value.

For Ex:

I am having the value FF0B in Result array and want increment it to FF0C. Now Result array should contain two values.

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by Diwakar Gana
0

Dear All,

Can anybody tell me how to autoincrement the Hexa decimal value.

For Ex:

I am having the value FF0B in Result array and want increment it to FF0C. Now Result array should contain two values.

(I assume you mean 'increment' because I think 'autoincrement' refers to database table columns.) When you increment a hex string the result is an ordinary decimal number which you have to reformat as a hex string if that's what you want.

#!/usr/bin/perl
use strict;
use warnings;

#Create results array containing one value
my @results = ('FF0B');

#Add 1 to first element and format as hex string for second element
push @results, sprintf('%04X', hex($results[0]) + 1);

#Results array now contains FF0B, FF0C
print 'Results array now contains ', join(', ', @results), "\n";

Edited by d5e5: n/a

This question has already been answered. Start a new discussion instead.
Take the time to help us to help you. Please be thoughtful and detailed and be sure to adhere to our posting rules.