Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

decimal/octal/hexadecimal in Java

Name: Anonymous 2009-02-06 6:23

int decVal = 26;     // The number 26, in decimal
int octVal = 032;     // The number 26, in octal
int hexVal = 0x1a;    // The number 26, in hexadecimal

like is there any speed advantage in what you choose?

Name: Anonymous 2009-02-06 6:27

lol

Name: Anonymous 2009-02-06 6:30

26::Dec
32::Oct
1A::Hex
26.0::Float

Name: Anonymous 2009-02-06 7:02

lol

Name: Anonymous 2009-02-06 8:38

>>1
Computars think in binary, so the fastest would be int binVal = 0b11010, however translation from hex is pretty straightforward too, octal would be somewhat slower and the slowest by far would be decimal, except if your compiler supports pragma for BCD operations.

So you'd better use hex, as all true hackers (in the original meaning) do!

Name: Anonymous 2009-02-06 8:43

Octal is fastest because it is closest to the 8bit-in-a-byte pattern.

Name: Anonymous 2009-02-06 8:46

Decimal is the fastest for short numbers, while hexadecimal is faster for longer numbers.

Name: Anonymous 2009-02-06 9:05

If you compile it to bytecode it all becomes the same, no?

Name: Anonymous 2009-02-06 9:42

>>8
It still has to be parsed and compiled.

Name: Anonymous 2009-02-06 10:00

section_3_1_1 = do

   withdraw 25
   withdraw 25
   Control.Exception.catch (withdraw 60 >>= print) print
   withdraw 15
   readIORef balance >>= print

   newWithdraw' <- newWithdraw
   newWithdraw' 25
   newWithdraw' 25
   Control.Exception.catch (newWithdraw' 60 >>= print) print
   newWithdraw' 15 >>= print

   b1 <- newIORef 100
   let w1 = makeWithdraw b1
   b2 <- newIORef 100
   let w2 = makeWithdraw b2
   w1 50
   w2 70
   Control.Exception.catch (w2 40 >>= print) print
   w1 40
   readIORef b1 >>= print
   readIORef b2 >>= print

   acc <- makeAccount 100
   accountWithdraw acc 50
   Control.Exception.catch (accountWithdraw acc 60 >>= print) print
   accountDeposit acc 40
   accountWithdraw acc 60
   accountBalance acc >>= print

   acc2 <- makeAccount 100

Name: Anonymous 2009-02-06 10:03

>>10

?

Name: MR SATORI !MhMRSATORI 2009-02-06 10:07

Hey guys, my name is MR SATORI

Name: Anonymous 2009-02-06 10:09

>>11
Haven't you read your SICP today?

Name: Anonymous 2009-02-06 10:19

>>13
SICP is a useless piece of shit. ZEN!

Name: Anonymous 2009-02-06 10:36

>>12
LIAR!

I happened to have reached SATORI last night and you weren't there.

Name: Anonymous 2009-02-06 12:38

Actually decimal is fastest because you don't have to use your head to convert it while reading the code.

Name: Anonymous 2009-02-06 12:56

>>16
Only if you think in decimal. What kind of crappy Java programmer are you?

Name: Anonymous 2009-02-06 21:31

i hate octals

Name: Anonymous 2009-02-06 21:41

All of these are shitty amateur hacks, and nothing more. Real Java Programmers use an AbstractConstantsFactoryFactorySingleton, an associated XML loader, and retrieve their constants from a dynamically generated file on their Enterprise Edition Constants Server which allows increased flexibility of the code and easy redeployment on any system throughout the world while keeping a realtime-equivalent performance and maximizing their productivity through their object-oriented frameworks.

Name: Anonymous 2009-02-06 22:02

Please don't make troll posts.  Thank you.

Name: Anonymous 2011-11-24 11:53

>>22
nice doubles bro

Name: Anonymous 2011-11-24 12:05

Thanks

Name: Anonymous 2011-11-24 13:09


>cat anus.java
public class anus
{
    public static void main(String args[])
    {
        int decVal = 26;
        int octVal = 032;
        int hexVal = 0x1a;
    }
}
>javap -c anus
Compiled from "anus.java"
public class anus extends java.lang.Object{
public anus();
  Code:
   0:   aload_0
   1:   invokespecial   #1; //Method java/lang/Object."<init>":()V
   4:   return

public static void main(java.lang.String[]);
  Code:
   0:   bipush  26
   2:   istore_1
   3:   bipush  26
   5:   istore_2
   6:   bipush  26
   8:   istore_3
   9:   return

}



it doesn't make a difference.

Name: Anonymous 2011-11-24 13:40

Java
GC is shit.

>>23
no shit, matlock

Name: Anonymous 2011-11-24 16:07

>>24
If it ain't GC, it's crap.

Name: Anonymous 2011-11-24 19:02

>>19-chan, daisuki!

My programs are so sugoi now.

Name: Anonymous 2012-11-25 14:32


Don't change these.
Name: Email:
Entire Thread Thread List