Programming/C Win32 MFC2025. 10. 11. 18:22

대부분의 경우 소수점 자리만 제한하는데

정수쪽도 길이 제한할일이 있어서 찾아보는데 묘하게 자료가 없어서 테스트 해봄

다만 리눅스에서 한거라 윈도우에서는 다를수 있음

 

void main()
{
	float a = -12.12334;
	printf("%f\n", a);
	printf("%4.1f\n",a);
	printf("%5.1f\n",a);
	printf("%6.1f\n",a);

	printf("%7.1f\n",a);
 	printf("%7.2f\n",a);
	printf("%7.3f\n",a);
   
	printf("%9.1f\n",a);
	printf("%9.2f\n",a);
	printf("%9.3f\n",a);
}

 

$ ./a.out 
-12.123340
-12.1
-12.1
 -12.1
  -12.1
 -12.12
-12.123
    -12.1
   -12.12
  -12.123

 

 

%7.1f / %7.2f / %7.3f 와

%9.1f / %9.2f / %9.3f 가

어떻게 보면 내가 하고 싶었던 결과인데 자리를 정리하면 아래와 같이 나온다.

  1 2 3 4 5 6 7 8 9
%7.3f - 1 2 . 1 2 3    
%9.3f     - 1 2 . 1 2 3

 

정리하자면

%n.mf 에서

n은 정수 부분, 소수점, 부호 를 포함한 전체 길이이고

m은 그중 소수점의 자릿수. m은 n 보다 작아야 한다.

 

'Programming > C Win32 MFC' 카테고리의 다른 글

free(): invalid next size (normal)  (0) 2023.12.18
c에서 cpp 함수 불러오기  (0) 2023.01.04
MSB / LSB 변환  (0) 2022.08.29
kore - c restful api server  (1) 2022.07.07
fopen exclusivly  (0) 2021.07.09
Posted by 구차니

대충~ 3.10 부터 추가되었다는 이야기

 

def http_error(status):
    match status:
        case 400:
            return "Bad request"
        case 404:
            return "Not found"
        case 418:
            return "I'm a teapot"
        case _:
            return "Something's wrong with the internet"
Note the last block: the “variable name” _ acts as a wildcard and never fails to match. If no case matches, none of the branches is executed.

You can combine several literals in a single pattern using | (“or”):

case 401 | 403 | 404:
    return "Not allowed"

class Point:
    x: int
    y: int

def where_is(point):
    match point:
        case Point(x=0, y=0):
            print("Origin")
        case Point(x=0, y=y):
            print(f"Y={y}")
        case Point(x=x, y=0):
            print(f"X={x}")
        case Point():
            print("Somewhere else")
        case _:
            print("Not a point")

[링크 : https://docs.python.org/ko/3.10/tutorial/controlflow.html#match-statements]

[링크 : https://okeybox.tistory.com/395]

[링크 : https://leapcell.io/blog/ko/python-eseo-switch-muneul-jakseonghaneun-bangbeop-2025-switch-case-yeeje]

[링크 : https://www.bangseongbeom.com/python-switch-case]

 

PEP - Program Enhance Proposal

[링크 : https://wikidocs.net/7896]

 

2020년에 작성되었고, 3.10 버전에 추가됨.

PEP 636 – Structural Pattern Matching: Tutorial
Author: Daniel F Moisset <dfmoisset at gmail.com>
Sponsor: Guido van Rossum <guido at python.org>
BDFL-Delegate:
Discussions-To: Python-Dev list
Status: Final
Type: Informational
Created: 12-Sep-2020
Python-Version: 3.10
Post-History: 22-Oct-2020, 08-Feb-2021
Resolution: Python-Committers message

[링크 : https://peps.python.org/pep-0636/]

 

아니 본인이 2006년에 썼다가 reject 했어?

PEP 3103 – A Switch/Case Statement
Author:Guido van Rossum <guido at python.org>
Status:Rejected
Type:Standards Track
Created:25-Jun-2006
Python-Version:3.0
Post-History:26-Jun-2006

[링크 : https://peps.python.org/pep-3103/]

'Programming > python(파이썬)' 카테고리의 다른 글

python simsimd  (0) 2025.08.28
python 원하는 버전 설치 및 연결하기  (0) 2025.08.26
pip 패키지 완전 삭제하기  (0) 2025.08.13
pip install cmake build multi core support  (0) 2025.08.13
python 빌드 정보  (0) 2025.08.04
Posted by 구차니
Programming/web 관련2025. 9. 5. 17:42

'Programming > web 관련' 카테고리의 다른 글

restful API  (0) 2025.07.15
html custom tag  (0) 2025.05.14
polypill  (0) 2025.03.05
css 캐로젤  (0) 2024.11.12
webgl + three.js를 이용한 GL 공부하기 (feat 클로드)  (0) 2024.10.18
Posted by 구차니

python 자체적으로 auto vectorization을 지원하는지 모르겠고

-O2 밖에 안되서 어떻게 될지 모르겠지만 혹시나 cython 이라던가 이쪽에서 지원하지 않을가 해서 검색해보니

먼가 하나 나와서 테스트 중

 

설치는 간단하고

# pip3 install simsimd
Collecting simsimd
  Downloading simsimd-6.5.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.metadata (70 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 70.5/70.5 kB 758.3 kB/s eta 0:00:00
Downloading simsimd-6.5.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (563 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 563.2/563.2 kB 4.6 MB/s eta 0:00:00
Installing collected packages: simsimd
Successfully installed simsimd-6.5.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[링크 : https://pypi.org/project/simsimd/]

 

확인도 간단한데

그나저나.. arm aarch64 에서는 neon이 활성화 되는데

10세대 모바일 프로세서에서는 왜.. haswell 이라고 하나만 활성화 될까? skylake 정도는 활성화 되어야 하는거 아닌가?

imx8mp aarch64 i7-10510U x64
>>> import simsimd
>>> print(simsimd.get_capabilities())
{'serial': True, 'neon': True, 'sve': False, 'neon_f16': False, 'sve_f16': False, 'neon_bf16': False, 'sve_bf16': False, 'neon_i8': False, 'sve_i8': False, 'haswell': False, 'skylake': False, 'ice': False, 'genoa': False, 'sapphire': False, 'turin': False, 'sierra': False}
>>> import simsimd
>>> print(simsimd.get_capabilities())
{'serial': True, 'neon': False, 'sve': False, 'neon_f16': False, 'sve_f16': False, 'neon_bf16': False, 'sve_bf16': False, 'neon_i8': False, 'sve_i8': False, 'haswell': True, 'skylake': False, 'ice': False, 'genoa': False, 'sapphire': False, 'turin': False, 'sierra': False}
Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp vnmi md_clear flush_l1d arch_capabilities
vmx flags : vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple pml ept_mode_based_exec
bugs : spectre_v1 spectre_v2 spec_store_bypass swapgs itlb_multihit srbds mmio_stale_data retbleed eibrs_pbrsb gds bhi

 

그런데 dot 이랑 cosine이랑 무슨 차이지 계산한 값이 많이 다른 느낌인데..

simsimd.cos()는 1 에서 빼줘야 맞다.

Posted by 구차니
Programming/node.js2025. 8. 26. 17:08

app.asar 이라는 파일이 있어서 찾아보니 electron의 컴파일(?)된 파일이라고 한다.

압축되어 있다는데 data 파일로만 나와서 zip 등으로 풀순 없고

npx asar extract 명령을 통해서 특정 디렉토리에 풀면된다.

 

$ npx asar extract app.asar asarResources
Need to install the following packages:
  asar
Ok to proceed? (y) 
npm WARN deprecated asar@3.2.0: Please use @electron/asar moving forward.  There is no API change, just a package name change
npm WARN deprecated @types/minimatch@6.0.0: This is a stub types definition. minimatch provides its own type definitions, so you do not need this installed.
npm WARN deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm WARN deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.

[링크 : https://til.jooy2.com/language/javascript/library-and-frameworks/electron/unpack-asar-file-format]

[링크 : https://richong.tistory.com/447]

 

$ asar pack app app.asar --unpack *.node

[링크 : https://www.electronjs.org/docs/latest/tutorial/asar-archives]

'Programming > node.js' 카테고리의 다른 글

node excel export  (0) 2024.07.18
web qr decoder  (0) 2024.04.04
node.js 웹소켓 채팅 서버 예제  (0) 2022.07.14
ubuntu 18.04 / nodej.s 18.x 실패  (0) 2022.05.19
웹소켓  (0) 2022.03.25
Posted by 구차니

ppa 추가해서 원하는 버전 설치하고, update-alternatives로 연결하면 된다.

 

sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.7

[링크 : https://askubuntu.com/questions/1251318/how-do-you-install-python3-7-to-ubuntu-20-04]

 

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1

[링크 : https://sosodev.tistory.com/entry/Python-pyenv-특정-버전을-설치하기-Ubuntu]

'Programming > python(파이썬)' 카테고리의 다른 글

python switch-case -> match-case  (0) 2025.10.11
python simsimd  (0) 2025.08.28
pip 패키지 완전 삭제하기  (0) 2025.08.13
pip install cmake build multi core support  (0) 2025.08.13
python 빌드 정보  (0) 2025.08.04
Posted by 구차니
Programming/openGL2025. 8. 20. 19:14

'Programming > openGL' 카테고리의 다른 글

openGL display list, deprecated  (0) 2025.08.20
visual studio 2002 에서 openGL 예제 실행  (0) 2025.07.30
openGL light  (0) 2025.07.30
openGL shade  (0) 2025.07.30
openGL 은선제거  (0) 2025.07.29
Posted by 구차니
Programming/openGL2025. 8. 20. 19:12

예전 openGL 책보다가 매번 해보지 못했던 부분인데

[링크 : http://www.gisdeveloper.co.kr/?p=76]

 

deprecated 되었다고 한다.

Note that these features were deprecated in 3.0, and actually removed in 3.1 (but still provided compatibility via an ARB extension). In OpenGL 3.2, they moved these features into a 'compatibility' profile that is optional for driver writers to implement.

[링크 : https://stackoverflow.com/questions/4113989/why-were-display-lists-deprecated-in-opengl-3-1]

 

오래되긴 했네..

OpenGL 3.1

출시일: 2009년 3월 24일

[링크 : https://ko.wikipedia.org/wiki/OpenGL]

'Programming > openGL' 카테고리의 다른 글

openGL VAO ABO  (0) 2025.08.20
visual studio 2002 에서 openGL 예제 실행  (0) 2025.07.30
openGL light  (0) 2025.07.30
openGL shade  (0) 2025.07.30
openGL 은선제거  (0) 2025.07.29
Posted by 구차니

패키지를 삭제했는데 바로 재설치가 되서

캐시되었다는 말을 검색해보니 cache purge를 통해 완전히 날리고 설치할수 있다고 한다.

 

해보니 확실히 처음부터 하긴 한다.

$ time CMAKE_BUILD_PARALLEL_LEVEL=3 pip3 uninstall --break-system-packages -v dlibFound existing installation: dlib 20.0.0
Uninstalling dlib-20.0.0:
  Would remove:
    /home/minimonk/.local/lib/python3.12/site-packages/_dlib_pybind11.cpython-312-aarch64-linux-gnu.so
    /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/INSTALLER
    /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/METADATA
    /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/RECORD
    /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/WHEEL
    /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/licenses/LICENSE.txt
    /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/top_level.txt
    /home/minimonk/.local/lib/python3.12/site-packages/dlib/__init__.py
    /home/minimonk/.local/lib/python3.12/site-packages/dlib/__pycache__/__init__.cpython-312.pyc
  Will actually move:
    /home/minimonk/.local/lib/python3.12/site-packages/_dlib_pybind11.cpython-312-aarch64-linux-gnu.so
    /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/
    /home/minimonk/.local/lib/python3.12/site-packages/dlib/
Proceed (Y/n)? y
  Removing file or directory /home/minimonk/.local/lib/python3.12/site-packages/_dlib_pybind11.cpython-312-aarch64-linux-gnu.so
  Removing file or directory /home/minimonk/.local/lib/python3.12/site-packages/dlib-20.0.0.dist-info/
  Removing file or directory /home/minimonk/.local/lib/python3.12/site-packages/dlib/
  Successfully uninstalled dlib-20.0.0

real    0m4.584s
user    0m2.585s
sys     0m0.381s

$ time CMAKE_BUILD_PARALLEL_LEVEL=3 pip3 install --break-system-packages -v dlib
Using pip 24.0 from /usr/lib/python3/dist-packages/pip (python 3.12)
Defaulting to user installation because normal site-packages is not writeable
Collecting dlib
  Using cached dlib-20.0.0-cp312-cp312-linux_aarch64.whl
Installing collected packages: dlib
Successfully installed dlib-20.0.0

real    0m4.876s
user    0m4.363s
sys     0m0.347s


pip3 cache purge
Files removed: 54

 

[링크 : https://ufris.tistory.com/61]

'Programming > python(파이썬)' 카테고리의 다른 글

python simsimd  (0) 2025.08.28
python 원하는 버전 설치 및 연결하기  (0) 2025.08.26
pip install cmake build multi core support  (0) 2025.08.13
python 빌드 정보  (0) 2025.08.04
python용 얼굴탐지, 인식  (0) 2025.08.04
Posted by 구차니

pip로 설치되는 녀석중 빌드가 필요한 녀석이 있는데

dlib가 원인을 알수 없으나(?) odroid-c2 / armbian 에서 1코어만 빌드하지만

nxp imx8mp evk 에서는 3코어로 빌드해서 어떤 옵션을 주어야 되는지

웬만한건 다 검색하고 해봐도 안되서 cmake 환경변수로 찾아보니 먼가 나왔고 시도하니 된다!

 

$ pip3 install  --break-system-packages -v dlib
  Invoking CMake build: 'cmake --build . --config Release -- -j1'
  [  1%] Building CXX object dlib_build/CMakeFiles/dlib.dir/base64/base64_kernel_1.cpp.o

 

CMAKE_BUILD_PARALLEL_LEVEL=4 pip3 install  --break-system-packages -v dlib
  Invoking CMake build: 'cmake --build . --config Release -- -j4'
  [  3%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bit_stream/bit_stream_kernel_1.cpp.o
  [  3%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_2.cpp.o
  [  2%] Building CXX object dlib_build/CMakeFiles/dlib.dir/bigint/bigint_kernel_1.cpp.o

[링크 : https://cmake.org/cmake/help/latest/envvar/CMAKE_BUILD_PARALLEL_LEVEL.html#cmake-build-parallel-level]

'Programming > python(파이썬)' 카테고리의 다른 글

python 원하는 버전 설치 및 연결하기  (0) 2025.08.26
pip 패키지 완전 삭제하기  (0) 2025.08.13
python 빌드 정보  (0) 2025.08.04
python용 얼굴탐지, 인식  (0) 2025.08.04
python struct  (0) 2024.12.13
Posted by 구차니