Posts

java - Why does HALF_UP sometimes round down with double? -

the following code: double doublevalue = 1713.6; float floatvalue = 1713.6f; string fs = "%-9s : %-7s %-7s\n"; system.out.printf( fs, "", "double", "float" ); decimalformat format = new decimalformat("#0"); system.out.printf( fs, "tostring", string.valueof( doublevalue ), string.valueof( floatvalue ) ); format.setroundingmode( roundingmode.down ); system.out.printf( fs, "down", format.format( doublevalue ), format.format( floatvalue ) ); format.setroundingmode( roundingmode.half_down ); system.out.printf( fs, "half_down", format.format( doublevalue ), format.format( floatvalue ) ); format.setroundingmode( roundingmode.half_up ); system.out.printf( fs, "half_up", format.format( doublevalue ), format.format( floatvalue ) ); format.setroundingmode( roundingmode.up ); system.out.printf( fs, "up", format.format( doublevalue ), format.format( floatvalue ) ); produces result ( live...

How to fix error "Unfortunately, the process com.android.systemui has stopped" -

i'm working on streaming app streams internet feed of fm radio station. when app loads, , hit play button, emulator crashes, , following error: "unfortunately, process com.android.systemui has stopped" emulator returns lock screen, stream begins play regardless, , when unlock phone screen app returns normal. i think may problem emulator, not sure. i'm using genymotion android emulator. code follows: public class mainactivity extends activity { private boolean initialstate = true; private imagebutton button; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button = (imagebutton)findviewbyid(r.id.btnplay); button.setbackgroundcolor(color.black); button.setimagedrawable(scaleimage(contextcompat.getdrawable(this, r.drawable.playwhite),0.2f)); } public void playpause(view arg0) { // intent startintent = new intent(mainactivity.this,foregroundser...

model view controller - Is it recommended to use Node.js for an online room booking web application? -

i have build web application booking hostel rooms online. hostel has 78 independent clusters consisting of 11 rooms. has total 858 rooms. a user can take room individual or in group of 2-11 persons. there 3 entities in system: user, room , group. have sign-up on system , can join group or can take room. registrations starts week prior actual allotment day i.e. user can register can't book room. on actual allotment day, admin of group book rooms group members on first come first serve basis. allotment process hardly takes 30 mins. there 80-90 users simultaneously online on website book rooms. last year hosted app on shared web hosting on start of allotment process, site down. nobody able log-in , book rooms. existing app developed in php. so whole story. want re-write whole app using mvc architecture. thinking use node.js. technology stack best suitable application? can point me in right direction choosing architecture app? if want use mvc nodejs, give sails.js t...

java - String with up to 2 decimal places Android -

this question has answer here: double parameter 2 digits after dot in strings.xml? 3 answers currently in strings.xml have `<string name="price_string">my string price: %1$s</string>` the problem outputs 5, instead of 5.5. how format include 2 decimals? <string name="price_string">my string price: %0.2f$s</string>`

c# - Get all containing flags -

i have variable containing flags , wounder how i'm able check flags set. my flags. [flags] public enum button{ //can't have more 30 flags //if enum added or deleted need change loop in method addbutton // exit flags exit = 1 << 0, cancel = 1 << 1, abort = 1 << 2, close = 1 << 3, //proced flags accept = 1 << 4, ok = 1 << 5, submit = 1 << 6, //question flags no = 1 << 7, yes = 1 << 8, //save , load save = 1 << 9, saveall = 1 << 10, savenew = 1 << 11, open = 1 << 12, load = 1 << 12 } and here check flags (int = 1; <= 12; ++i) { if((buttons & 1 << i) == 1 << i){ } } apparently can't use way check flags. to clear want know flags set in buttons. update: can't ...

python - How to create DNS TXT record? -

i want create dns txt record type programmatically python code. did not find data of how doing or specific format of txt record. here how tried create txt record python: # copy id of request packet+=self.data[:2] # add flags of response packet+= "\x81\x80" # questions , answers counts packet+='\x00\x01' packet+='\x00\x01' #no records follow packet+='\x00\x00' # additional records follow packet+='\x00\x00' #packet+='\x00\x01' (urllist,urldatalength) = decodequery(self.data) urlposition = urldatalength # original domain name question packet+=self.data[12:12+urldatalength+4] # pointer domain name packet+='\xc0\x0c' #response type ~~~~~~~~~~~~~~~~ # response type (txt) packet+='\x00\x10' #class packet+='\x00\x01' #ttl packet+='\x00\x00\x02\x58' #d...

C float in NASM x86 assembly -

in university project have use binary representation of float number in x86 assembly arithmetic operations. using fpu forbidden try read float number , return dword whatever try "-nan". advices? edit: use gcc , it's 32 bit code declaration in c (i can't change that) extern "c" float func(float num); *.asm file section .text global func func: ;prolog push ebp mov ebp, esp ; zapamiętanie rejestrów zachowywanych push ebx push esi push edi mov eax, dword [ebp+8] ;mov eax, 0xffffffff checked still same result ; odtworzenie rejestrów, które były zapamiętane pop edi pop esi pop ebx ;epilog pop ebp ret example result (for 256) 01000011100000000000000000000000 11111111110000000000000000000000 num1: 256.000000 num2: -nan edit: c code without checking bits part #include <stdio.h> extern "c" float func(float num); int main() { float num1; float num2; scanf(...