Re: source code speed question

new topic     » goto parent     » topic index » view thread      » older message » newer message
bernie said...
Bernie said...

In DLL.E C_INT, C_LONG, etc. are constants initialized in HEX.

When using say a C_LONG does the program convert it to DECIMAL each time its used in the user's code or is it converted to DECIMAL only ONCE when it's defined as a constant ?

I know it is more convenient to use HEX in the source but wouldn't be faster to use all DECIMAL in the constants so no conversion would be required ?

Because you are using a character by character scan of a number

For example using the same number:

You see a HEX number in the code as '#' '1' '2' 'B'

You see a DECIMAL number in the code as '2' '9' '9'

Which is faster to scan ?

They take the same time.

When "constant" is first seen in your program, Euphoria converts it to a number in machine-code format - it is no longer text. From then on, when your program uses that constant, it actually uses the ready-to-use machine-code number so it doesn't have to convert it each time.

There is no perfomance advantage between writing constants using decimal notation or hexadecimal notatation. The best bet is to use whatever is best for humans to read the code in. Note that to aid human reading of source code numbers, we have introduced the grouping character for numeric literals. You can now use the underscore character inside a number literal to group digits together to aid legibility. For example ...

constant BigHex = #0F04_4AE0, 
         telephone = 02_555_1224, 
         pie = 9.347_377_E-3 
          
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu