Register | Login
Forum Index > Requests and Feedback > negative value inside enum
Author Message
Pages: 1
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[979] negative value inside enum - posted: 2011-12-08 19:31:57

i have this enum in c
Code:
enum BRANCH_TYPE
{
  JO = 1,
  JC,
  JE,
  JA,
  JS,
  JP,
  JL,
  JG,
  JB,
  JECXZ,
  JmpType,
  CallType,
  RetType,
  JNO = -1,
  JNC = -2,
  JNE = -3,
  JNA = -4,
  JNS = -5,
  JNP = -6,
  JNL = -7,
  JNG = -8,
  JNB = -9
};


i changed it to
Code:
enum BRANCH_TYPE : int32
{
  JO_ = 1,
  JC_,
  JE_,
  JA_,
  JS_,
  JP_,
  JL_,
  JG_,
  JB_,
  JECXZ_,
  JmpType_,
  CallType_,
  RetType_,
  JNO_ = -1,
  JNC_ = -2,
  JNE_ = -3,
  JNA_ = -4,
  JNS_ = -5,
  JNP_ = -6,
  JNL_ = -7,
  JNG_ = -8,
  JNB_ = -9,
}


but ziron did not allow nigative value inside enum.

so can this be made please.

http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[980] - posted: 2011-12-09 00:06:59
enum's do not support negative numbers intentionally... because enums are always unsigned

Code:
enum BRANCH_TYPE : int32
{
  JO_ = 1,
  JC_,
  JE_,
  JA_,
  JS_,
  JP_,
  JL_,
  JG_,
  JB_,
  JECXZ_,
  JmpType_,
  CallType_,
  RetType_,
}
const JNO_ = -1;
const JNC_ = -2;
const JNE_ = -3;
const JNA_ = -4;
const JNS_ = -5;
const JNP_ = -6;
const JNL_ = -7;
const JNG_ = -8;
const JNB_ = -9;


i may consider adding support for signed at a later date, but progress will be slow for the next month has I have alot of work this coming month or 2.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1816] - posted: 2015-03-03 11:40:32
enum's do not support negative numbers intentionally... because enums are always unsigned
# It is now possible to set the default increment of an enum by passing a parameter to the type.
e.g. enum NAME: DWord (2) { ...
Code:
program RAW_IMAGE 'test';

#set bits 32;

enum ENUM_X : Int32 (-4) {X0 = 0, X1, X2, X3, X4}

$echof 'X0 = ', X0;
$echof 'X1 = ', X1;
$echof 'X2 = ', X2;
$echof 'X3 = ', X3;
$echof 'X4 = ', X4;
Result:
X0 = 0
X1 = -4
X2 = -8
X3 = -12
X4 = -16
Seems currently negative values also supported.
Then need to add this information in our documentation.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1822] - posted: 2015-03-05 15:06:35
I will include this in documentation once i complete more of the documentation :P

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 2 user(s) online. 0 member(s) and 2 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd