Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 07-17-2005, 04:30 AM
deathemperor's Avatar
deathemperor deathemperor is offline
 
Join Date: Jul 2003
Location: HOL
Posts: 1,270
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

let me try to explain.

like the above example:

32
16
8
4
2
1

this is 65, in your database you have a field called permissionwhatever to store that number (65), and if a usergroup has that value 65 it means they have full permission, each bit represent for a permission. if it's 64, then the value you don't have must be 1, 60 means without 1 and 4 and it cannot be any other number. so that's the way it realizes you don't have what permission.
Reply With Quote
  #12  
Old 07-17-2005, 11:07 AM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Well ... all Powers of 2 except 2^0 are even.
So if a number is odd, it must have Bit 0 (2^0=1) set, so this functions checks for this Bit being set.
I don't understand the connection between 0 power and Bit 0? =//

Quote:
1*2^0 = 1*1 = 1
0*2^1 = 0*2 = 0
1*2^2 = 1*4 = 4
In Total: 5
How do you convert decimals to binarys?

Quote:
let me try to explain.

like the above example:

32
16
8
4
2
1

this is 65, in your database you have a field called permissionwhatever to store that number (65), and if a usergroup has that value 65 it means they have full permission, each bit represent for a permission. if it's 64, then the value you don't have must be 1, 60 means without 1 and 4 and it cannot be any other number. so that's the way it realizes you don't have what permission.
I understand this, thanks...
Reply With Quote
  #13  
Old 07-17-2005, 11:13 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Also have a look at this post: https://vborg.vbsupport.ru/showpost....62&postcount=4

Might help in understanding
Reply With Quote
  #14  
Old 07-17-2005, 12:04 PM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Okay, I already completely understand how the vB permissions work

What I do not understand is this:

Quote:
Originally Posted by Dark Visor
Quote:
Well ... all Powers of 2 except 2^0 are even.
So if a number is odd, it must have Bit 0 (2^0=1) set, so this functions checks for this Bit being set.
I don't understand the connection between 0 power and Bit 0? =//
Reply With Quote
  #15  
Old 07-17-2005, 12:07 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm, what exactly do you not understand?
2^0 = 1
2^1 = 2
2^2 = 4
2^3 = 8
2^4 = 16
...
As you can see, all numbers are even - except 1. So if you add them together, you will always get an even number if 1 is not included.
1 is 2^0, which means this bit must be set if a number is odd.
Reply With Quote
  #16  
Old 07-17-2005, 12:11 PM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh!!! Yeah, now I understand.
When a number is an even number, it consists of such sub-numbers, as 2,4,8,16, but not 1. And when a number is odd, it has 1 included, so 3 & 1 works This is so cool...

Thanks everyone.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:24 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04837 seconds
  • Memory Usage 2,209KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete